SUMIF with header criteria

MGCC

New Member
Joined
Jul 13, 2023
Messages
11
Office Version
  1. 365
Platform
  1. Windows
I've searched the internet far and wide for an answer to this question with no success. I'm hoping the brilliant minds in this forum can be of assistance.
ABCDEF
1​
CalcYESYESNOYESNO
2​
#nights33232
3​
MonthABCDE
4​
Jan5430123
5​
Jan75123
6​
Jan1877123
7​
Feb187730123
8​
Feb187730123
9​
Mar5430123
10​
Mar5430123

I need a formula which will return the value based on multiple criteria.
E.g. I want to know the value per night (Row 2) for Jan (Column A) if header is YES (Row 1). In this case it should be (54+75+1877)/Count (3)/ Nights (3) = 222.83

Any help with this would be a greatly appreciated.
 

Excel Facts

Difference between two dates
Secret function! Use =DATEDIF(A2,B2,"Y")&" years"&=DATEDIF(A2,B2,"YM")&" months"&=DATEDIF(A2,B2,"MD")&" days"
I want to know the value per night (Row 2) for Jan (Column A) if header is YES (Row 1). In this case it should be (54+75+1877)/Count (3)/ Nights (3) = 222.83
What would the calculation be if the #nights in the YES columns were not all the same?
For example, what would the value per night (Row 2) for Jan (Column A) if header is YES (Row 1) for the following sample data?

23 10 23.xlsm
ABCDEF
1CalcYESYESNOYESNO
2#nights332102
3MonthABCDE
4Jan5430123
5Jan75123
6Jan1877123
7Feb187730123
8Feb187730123
9Mar5430123
10Mar5430123
MGCC
 
Upvote 0
Hi, If the value is YES, number of night is always the same. Thank you
 
Upvote 0
Hi, If the value is YES, number of night is always the same. Thank you
See if this does what you want then.

23 10 23.xlsm
ABCDEFGHIJ
1CalcYESYESNOYESNOJanYES222.8889
2#nights33232
3MonthABCDE
4Jan5430123
5Jan75123
6Jan1877123
7Feb187730123
8Feb187730123
9Mar5430123
10Mar5430123
MGCC
Cell Formulas
RangeFormula
J1J1=AVERAGE(FILTER(FILTER(B4:F10,B1:F1=I1),A4:A10=H1))/XLOOKUP(I1,B1:F1,B2:F2)
 
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top