Long IF Formula Calculation Trouble

jarett

Board Regular
Joined
Apr 12, 2021
Messages
175
Office Version
  1. 365
  2. 2016
Platform
  1. Windows
I had noticed an inconsistency in my formula a week or two ago and I thought I corrected it but, I am noticing my output to the formula is incorrect again for some instances. The rows in question are row12-25, the total should be "12" not "13" if all the logic is correct, I don't know if the formula is counting a 0 on row 15 or why I am getting a "13" result. All other calculations for rows are correct. any issue seen in the formula?

Main_WIP.xlsx
ABCDEFGHIJKL
1SalesOrderNoItemCodeQuantityOrderedQuantityBackorderedUDF_QTY_PULLEDUDF_QTY_RECEIVEDUDF_PROCESSED_ICUDF_PROCESS_INCOMPLETEUDF_ALLOCATEDWarehouseCodeUDF_DATE_ALLOCATEDOH Addition
28492424112-CBLB-A1101NNY0007/29/2024 0:00 
38498813112-CBLB-A1101YNN0002
48498058112-CBLK-A1100NNN0000
58491574112-CBLW-A1101NNN000 
68500770112-CBLW-A1101NNN0002
70026473112-CCBI-A4404YNN0004
80024765112-CHB-A5050NNN000 
90026276112-CHB-A14476680NNN000 
100026410112-CHB-A360360YNN000 
110027042112-CHB-A1010NNY0007/30/2024 0:0037
120025756112-CHCBL-A1101NNY0006/28/2024 0:00 
138489735112-CHCBL-A1101NNN000 
148499180112-CHCBL-A1101NNY0008/1/2024 0:00 
158500792112-CHCBL-A0000NNY0008/7/2024 0:00 
168500876112-CHCBL-A1101NNN000 
178501125112-CHCBL-A1101NNY0008/7/2024 0:00 
188501400112-CHCBL-A1101NNY0008/6/2024 0:00 
198501846112-CHCBL-A1101NNY0008/6/2024 0:00 
208501895112-CHCBL-A1101NNY0008/6/2024 0:00 
218502328112-CHCBL-A1101NNN000 
228502581112-CHCBL-A1101NNY0008/7/2024 0:00 
238502703112-CHCBL-A1101NYY0008/7/2024 0:00 
248502729112-CHCBL-A1101NNY0008/7/2024 0:00 
258503482112-CHCBL-A1100NNN00013
268489735112-CHN-A1100NNN000 
278502648112-CHN-A3300NNN0000
280027695112-CHNBL-A121200NNN0000
InventoryCount
Cell Formulas
RangeFormula
L2:L28L2=IF(B2<>B3,SUMIF(B$2:B2,B2,F$2:F2)+SUMIFS(E$2:E2,K$2:K2,"<>"&TODAY(),I$2:I2,"Y",B$2:B2,B2)+SUMIFS(E$2:E2,G$2:G2,"Y",B$2:B2,B2,I$2:I2,"<>Y")+SUMIFS(E$2:E2,H$2:H2,"Y",B$2:B2,B2)+SUMIFS(F$2:F2,H$2:H2,"Y",B$2:B2,B2),"")
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
The 1st sumifs will return 12 & the last returns 1 so the total of 13 is correct.
 
Upvote 0
The 1st sumifs will return 12 & the last returns 1 so the total of 13 is correct.
So, if I need the last SUMIFS to equal 12 as well, I am not sure how I get that because I only have a max total of 12 in column E&F for the item code 112-CHCBL-A
 
Upvote 0
Its easier to spot the issue if you use SumIfs all the way through.
The first SumIf, sums all of F, the last Sumif, sums F again if H = Y and hence double counts those.
Under what conditions did you want F summed ?

Note: I'm not sure your Sum of column E are mutually exclusive either.

Rich (BB code):
=IF(B25<>B26,
  SUMIFS(F$2:F25,B$2:B25,B25)
  +SUMIFS(E$2:E25,K$2:K25,"<>"&TODAY(),I$2:I25,"Y",B$2:B25,B25)
  +SUMIFS(E$2:E25,G$2:G25,"Y",B$2:B25,B25,I$2:I25,"<>Y")
  +SUMIFS(E$2:E25,H$2:H25,"Y",B$2:B25,B25)
  +SUMIFS(F$2:F25,H$2:H25,"Y",B$2:B25,B25)
,"")
 
Upvote 0
Solution
Its easier to spot the issue if you use SumIfs all the way through.
The first SumIf, sums all of F, the last Sumif, sums F again if H = Y and hence double counts those.
Under what conditions did you want F summed ?

Note: I'm not sure your Sum of column E are mutually exclusive either.

Rich (BB code):
=IF(B25<>B26,
  SUMIFS(F$2:F25,B$2:B25,B25)
  +SUMIFS(E$2:E25,K$2:K25,"<>"&TODAY(),I$2:I25,"Y",B$2:B25,B25)
  +SUMIFS(E$2:E25,G$2:G25,"Y",B$2:B25,B25,I$2:I25,"<>Y")
  +SUMIFS(E$2:E25,H$2:H25,"Y",B$2:B25,B25)
  +SUMIFS(F$2:F25,H$2:H25,"Y",B$2:B25,B25)
,"")
F should be summed always, if it has a quantity it should be counted (even if negative). Column E should be counted if column G or H is = Y or if (Column I is = Y and Column K <> todays date). I removed the last SUMIFS and the lines that I was getting the incorrect calculation came out correct, I think with that last SUMIFS it was counting Row 23 twice like you said.
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Just be aware that while these 2 lines summing column E are mutually exclusive:
Rich (BB code):
  +SUMIFS(E$2:E25,K$2:K25,"<>"&TODAY(),I$2:I25,"Y",B$2:B25,B25)
  +SUMIFS(E$2:E25,G$2:G25,"Y",B$2:B25,B25,I$2:I25,"<>Y")

This line is not and has the potential to double count:
Excel Formula:
  +SUMIFS(E$2:E25,H$2:H25,"Y",B$2:B25,B25)
 
Upvote 0

Forum statistics

Threads
1,221,310
Messages
6,159,176
Members
451,543
Latest member
cesymcox

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