问题
My SUMIFS needs to add up column D (D11:D172) and the first criteria is a range called qbplistcomp (which is column B so B11:B172) for multiple hits (e.g. CHF, COPD, and all STROKE so using STROKE*) and the second criteria is in column C (C11:C172) looking for the criteria which is a label "qbp volumes" ... so far without subtotaling, this formula works as:
=SUM(SUMIFS(D11:D172,qbplistcomp,{"CHF","COPD","STROKE*"},C11:C172,"QBP Volumes")) Now my column A has the ability to filter on Category, so if I choose say just "stroke" it should only subtotal (sum) just those ones ... keep getting error ... help, thanks, Tina
回答1:
Interesting question.. Why? It gives us a very multidimensional fomula combining SumIfs and Subtotal.
My examples formula..
=SUMPRODUCT((A6:A17=A2)*(B6:B17={"North","West","East"})*(SUBTOTAL(103,OFFSET(B6,ROW(B6:B17)-MIN(ROW(B6:B17)),0)))*(C6:C17))
And hence your formula should be
SUMPRODUCT((C11:C172="QBP Volumes")*(B11:B172={"CHF","COPD","STROKE*"})*(SUBTOTAL(103,OFFSET(B11,ROW(B11:B172)-MIN(ROW(B11:B172)),0)))*(D11:D172))
See When the B Col is NOT filtered for "North" C2= 38859 i.e. total for A in North and West
When the B Col is filtered for "North" C2= 32313 i.e. total for A ONLY in North
Remember, subtotal formula is applicable to the column you are supposed to filter(Col B). If you intend the same for Col c then replace(C11:C172="QBP Volumes")
with subtotal formula so your new formula will be SUMPRODUCT((SUBTOTAL(103,OFFSET(C11,ROW(C11:C172)-MIN(ROW(C11:C172)),0)))*(B11:B172={"CHF","COPD","STROKE*"})*(SUBTOTAL(103,OFFSET(B11,ROW(B11:B172)-MIN(ROW(B11:B172)),0)))*(D11:D172))
来源:https://stackoverflow.com/questions/60623143/excel-2016-combine-subtotal-with-sumifs