SUMIF - What am I doing wrong?

Demonsguile

New Member
Joined
Oct 13, 2011
Messages
39
I'd like some help understanding why this formula doesn't work. The formula looks at multiple conditions:
1. Unit # (column J)
2. Fee (column K)
3. Date (column I)

If all three conditions are met, it should return the sum of everything that meets the conditions. However, if I include either "Re Inspection Fee -" or "Late Fee -", the formula returns the respective value. By adding both, it returns nothing. Or, more accurately, it returns 0.00 when it should return something. Why isn't this working? It obviously works as expected for the Unit #. Help?

Excel Formula:
=SUM(SUMIFS('Ledger - Details'!$L:$L, 'Ledger - Details'!$J:$J, {"UNITA","UNITB","UNITC","UNITD"}, 'Ledger - Details'!$K:$K, {"Re Inspection Fee -","Late Fee -"}, 'Ledger - Details'!$I:$I, AM$1))*-1
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I believe the issue relates to a mismatch in the array dimensions. With only one criteria listing 4 match items (the Units), the other singular criteria (a fee term and a date) are applied to each of the 1st items with an AND condition. As soon as you add a 2nd dimension to one of the other matching arrays (e.g., the Fees), then the formula attempts to match the conditions differently: UNITA to Re Inspection Fee - and the next is UNITB to Late Fee -, and there is nothing to match with UNITC and UNITD. You could repeat the SUMIFS function inside the SUM (so you'd have two SUMIFS functions), with the first specifying only one fee term and the other specifying the other fee term to see if that returns the expected value.

What version of Excel are you using?
 
Last edited:
Upvote 0
You could try adapting this type of approach...here I sum values in column C where there are 3 match items in B and 2 match items in D. The vertical arrays of 1's (uses semicolons) are of whatever length matches the number of match criteria for that item.
Book1
BCD
1
210
3
4a1x
5b2x
6c3x
7b4y
8d5x
9d6y
10e7z
Sheet3
Cell Formulas
RangeFormula
D2D2=SUMPRODUCT(C4:C10,MMULT(--(B4:B10={"a","b","c"}),{1;1;1}),MMULT(--(D4:D10={"x","y"}),{1;1}))
 
Upvote 0
I believe the issue relates to a mismatch in the array dimensions. With only one criteria listing 4 match items (the Units), the other singular criteria (a fee term and a date) are applied to each of the 1st items with an AND condition. As soon as you add a 2nd dimension to one of the other matching arrays (e.g., the Fees), then the formula attempts to match the conditions differently: UNITA to Re Inspection Fee - and the next is UNITB to Late Fee -, and there is nothing to match with UNITC and UNITD. You could repeat the SUMIFS function inside the SUM (so you'd have two SUMIFS functions), with the first specifying only one fee term and the other specifying the other fee term to see if that returns the expected value.

What version of Excel are you using?
Thank you for the quick response. I'm using MS Office Pro Plus 2016.
I modified the formula to include four variables (two of them are bogus, though) to see if that would do the trick. I got the same result, which returned 0.00.

Excel Formula:
=SUM(SUMIFS('Ledger - Details'!$L:$L, 'Ledger - Details'!$J:$J, {"UNITA","UNITB","UNITC","UNITD"}, 'Ledger - Details'!$K:$K, {"Late Fee -","Re Inspection Fee -","A","B"}, 'Ledger - Details'!$I:$I, AM$1))*-1
 
Last edited:
Upvote 0
You could try adapting this type of approach...here I sum values in column C where there are 3 match items in B and 2 match items in D. The vertical arrays of 1's (uses semicolons) are of whatever length matches the number of match criteria for that item.
Book1
BCD
1
210
3
4a1x
5b2x
6c3x
7b4y
8d5x
9d6y
10e7z
Sheet3
Cell Formulas
RangeFormula
D2D2=SUMPRODUCT(C4:C10,MMULT(--(B4:B10={"a","b","c"}),{1;1;1}),MMULT(--(D4:D10={"x","y"}),{1;1}))
Thank you. I'll take a closer look and see if I can adapt it. I'll be honest in that I'm not quite sure what the {1;1;1} is supposed to do. But, I'll try to figure it out.
 
Upvote 0
I got the same result, which returned 0.00
That's likely because of the way the AND condition is applied...the formula is only considering UNITA AND Late Fee, UNIT B AND Re Inspection Fee, UNITC AND A, and UNITD AND B. The last criteria involving column I is applied to all.

Have a look at my suggestion in post #3. With that approach, you'll have to count the number of matching criteria (so 4 for the Units and 2 for the Fees) and construct the vertical arrays {1;1;1;1} and {1;1}, respectively. Essentially, this approach produces intermediate vertical arrays for each of the match criteria (so a 4-column array indicating which rows match each of the Units items, and a 2-column array for which rows match each of the Fees items)...then to convert each of these multi-column arrays into single column arrays indicating that any of the matching terms were found on each row, we mutliply the multi-column array by a vertical array of 1's (so the number of columns in the first array needs to match the number of 1's in the vertical array).

Here is an example similar to yours with a 3 item array for matching in one column, a 2 item array for matching in a second column, and a single item for matching in a third column:
Book1
BCDE
1
27
3
4a1xdog
5b2xdog
6c3xcat
7b4ydog
8d5xcat
9d6ydog
10e7zdog
Sheet3
Cell Formulas
RangeFormula
D2D2=SUMPRODUCT(C4:C10,MMULT(--(B4:B10={"a","b","c"}),{1;1;1}),MMULT(--(D4:D10={"x","y"}),{1;1}),--(E4:E10="dog"))
 
Upvote 0
I figured it might be easier if I provided the actual data-set that I'm working with:
Book1
ABCD
1DateUnitDescriptionAmount
27/1/2022BuildingManagement Fees--27.47
37/1/2022UNITCRent -274.67
47/1/2022BuildingManagement Fees--258.7
57/1/2022UNITCLate Fee -150
67/1/2022UNITCRe Inspection Fee -84.67
77/1/2022UNITCRent -240.33
87/1/2022BuildingYard --54.13
97/1/2022UNITDRepairs--125
107/1/2022BuildingYard --54.13
117/1/2022UNITBRent -500
127/1/2022UNITDRent -515
137/1/2022UNITDLate Fee -35
147/1/2022UNITARent -475
157/1/2022BuildingManagement Fees--184
167/1/2022UNITCRent -515
177/1/2022BuildingManagement Fees--51.5
Sheet1


I am looking for a way to match three criteria (Unit, Fee, and Date) and sum them if they all match. For example, the formula should return $269.67 (Two late fees and a Reinspection Fee).
 
Upvote 0
Try this:
Book1
ABCDEF
1DateUnitDescriptionAmount269.67
27/1/2022BuildingManagement Fees--27.47
37/1/2022UNITCRent -274.67
47/1/2022BuildingManagement Fees--258.7
57/1/2022UNITCLate Fee -150
67/1/2022UNITCRe Inspection Fee -84.67
77/1/2022UNITCRent -240.33
87/1/2022BuildingYard --54.13
97/1/2022UNITDRepairs--125
107/1/2022BuildingYard --54.13
117/1/2022UNITBRent -500
127/1/2022UNITDRent -515
137/1/2022UNITDLate Fee -35
147/1/2022UNITARent -475
157/1/2022BuildingManagement Fees--184
167/1/2022UNITCRent -515
177/1/2022BuildingManagement Fees--51.5
18
19
20
Sheet4
Cell Formulas
RangeFormula
F1F1=SUMPRODUCT(D2:D20,MMULT(--(B2:B20={"UNITA","UNITB","UNITC","UNITD"}),{1;1;1;1}),MMULT(--(C2:C20={"Re Inspection Fee -","Late Fee -"}),{1;1}),--(A2:A20=DATE(2022,7,1)))
 
Upvote 0
Solution
Try this:
Book1
ABCDEF
1DateUnitDescriptionAmount269.67
27/1/2022BuildingManagement Fees--27.47
37/1/2022UNITCRent -274.67
47/1/2022BuildingManagement Fees--258.7
57/1/2022UNITCLate Fee -150
67/1/2022UNITCRe Inspection Fee -84.67
77/1/2022UNITCRent -240.33
87/1/2022BuildingYard --54.13
97/1/2022UNITDRepairs--125
107/1/2022BuildingYard --54.13
117/1/2022UNITBRent -500
127/1/2022UNITDRent -515
137/1/2022UNITDLate Fee -35
147/1/2022UNITARent -475
157/1/2022BuildingManagement Fees--184
167/1/2022UNITCRent -515
177/1/2022BuildingManagement Fees--51.5
18
19
20
Sheet4
Cell Formulas
RangeFormula
F1F1=SUMPRODUCT(D2:D20,MMULT(--(B2:B20={"UNITA","UNITB","UNITC","UNITD"}),{1;1;1;1}),MMULT(--(C2:C20={"Re Inspection Fee -","Late Fee -"}),{1;1}),--(A2:A20=DATE(2022,7,1)))
You are a genius and a scholar. Thank you! I still am unclear on why it works, but I'm going to figure it out.
Thanks again!
 
Upvote 0
Here is another option (green cells) based on my earlier point. Using SUMIFS, you'll need to use no more than one multi-dimensional array because the function will not treat them as OR conditions, and will instead consider only the 1st items of each matching criteria to be an AND condition (this is confusing). So the first row illustrates how the 4-column array for the UNITA, UNITB, UNITC, and UNITD matching returns all 0's (there are no UNITA AND Re Inspection Fee- AND 7/1/2022 rows, etc.). The next row shows the results when the 2nd two-item fee array is split to consider only one of the terms (Re Inspection Fee-). The next row shows the results when the other fee term is used. The next row combines the two previous ones. The last row wraps this 4-column resultant array with a SUM function to obtain the final result.
Book1
HIJKL
1unitAunitBunitCunitD
20000trying to combine mismatched arrays with AND condition
30084.670using only one multi-column array and splitting other
40015035using only one multi-column array and splitting other
500234.6735using the two SUMIFS above and summing them
6269.67wrapping the result immediately above with SUM to sum all columns
Sheet4
Cell Formulas
RangeFormula
H2:K2H2=SUMIFS(D2:D20,B2:B20,{"UNITA","UNITB","UNITC","UNITD"},C2:C20,{"Re Inspection Fee -","Late Fee -"},A2:A20,DATE(2022,7,1))
H3:K3H3=SUMIFS(D2:D20,B2:B20,{"UNITA","UNITB","UNITC","UNITD"},C2:C20,"Re Inspection Fee -",A2:A20,DATE(2022,7,1))
H4:K4H4=SUMIFS(D2:D20,B2:B20,{"UNITA","UNITB","UNITC","UNITD"},C2:C20,"Late Fee -",A2:A20,DATE(2022,7,1))
H5:K5H5=SUMIFS(D2:D20,B2:B20,{"UNITA","UNITB","UNITC","UNITD"},C2:C20,"Re Inspection Fee -",A2:A20,DATE(2022,7,1)) + SUMIFS(D2:D20,B2:B20,{"UNITA","UNITB","UNITC","UNITD"},C2:C20,"Late Fee -",A2:A20,DATE(2022,7,1))
H6H6=SUM(SUMIFS(D2:D20,B2:B20,{"UNITA","UNITB","UNITC","UNITD"},C2:C20,"Re Inspection Fee -",A2:A20,DATE(2022,7,1)) + SUMIFS(D2:D20,B2:B20,{"UNITA","UNITB","UNITC","UNITD"},C2:C20,"Late Fee -",A2:A20,DATE(2022,7,1)))
Dynamic array formulas.
 
Upvote 0

Forum statistics

Threads
1,215,429
Messages
6,124,839
Members
449,193
Latest member
MikeVol

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