Sumif Formula with no duplicates - excel

I am trying to have sumif formula which avoid duplicates. For example if something has been summed in the above rows, I don’t want it to be summed again if it’s down in the below rows, can you please assist?
=SUMIF($R$50:$R$54,R50,$AG$50:$AG$54)
Thanks

Are you able to add another column for additional criteria?
For example, if you add another column (let's say it's in column A) with the formula
=IF(COUNTIF($R$50:R50,R50)=1,1,0)
The formula above will return a 1 if the value in Cell R50 is unique, and a 0 if it is not. Now change your SumIf function to SumIfs. You could use
=SUMIFS($AG$50:$AG$54,$R$50:$R$54,R50,$A$50:$A$54,1)
to return the sum of only unique values.
The SumIfs function is pretty much a SumIf function, but with the ability to use multiple criteria without the need for an array function. SumIf criteria is SUMIFS(sum_range, criteria_range1, criteria1, [criteria_range2, criteria2], ...), so we are returning the sum of all values in AG50:AG54 where the value in R50:R54 matches that of R50 AND the unique flag in A50:A54 equals 1.
Edit
I should clarify that the SUMIFS formula isn't available in Office 2003 and below. If this means you cannot use SUMIFS, I believe you will need an array formula, let me know.

=IF($R84=$R83,"",SUMIFS($AG:$AG,$R:$R,$R84,$S:$S,$S84))

Related

Countifs does not work when a range with multiple column is selected

I need a count if function that counts me the cells that meet a certain criteria. This should be done with countifs. The formula is the following:
=COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:Q;">=1")This formula returns me an value type error.
This formula works well until I introduce the last condition orders!K:Q;">=1"
I would like a formula that counts if the word Ecolab is present in the cell; if the date is after or equal 01/01/2019; if the column U has more or equal than the number 36 and if there is at least a "1" in the cells in the row from column K to column Q. I could do this by easily replicating the countifs several times, (i.e =COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!K:K;">=1")+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!L:L;">=1")+...........+COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";Orders!Q:Q;">=1")
But I would rather not include such a long formula as it would create confusion for the ultimate user of the excel sheet
Per my comment above, you could use SUMPRODUCT (avoid using whole columns for that) or an array with OFFSET like this:
=SUM(COUNTIFS(Orders!D:D;"*Ecolab*";Orders!B:B;">=01/01/2019";Orders!U:U;">=36";OFFSET(Orders!J:J;0;{1;2;3;4;5;6;7});">=1"))
If the count for K:Q should be 1 when there may be more than one cell greater or equal to 1 in a single row then you need to apply OR criteria in a SUMPRODUCT.
SUMPRODUCT formulas should not use full column references; there is too much wasted calculation. The following is for rows 2:99; adjust for your own use.
=SUMPRODUCT(--ISNUMBER(SEARCH("ecolab", Orders!D2:D99)),
--(Orders!B2:B99>=DATE(2019, 1, 1)),
--(Orders!U2:U99>=36),
SIGN((Orders!K2:K99>=1)+(Orders!L2:L99>=1)+(Orders!M2:M99>=1)+(Orders!N2:N99>=1)+(Orders!O2:O99>=1)+(Orders!P2:P99>=1)+(Orders!Q2:Q99>=1)))

SUMIFS Formula With Empty Criteria in Cell Reference

My SUMIFS formula gets its criteria from a drop down filter. Need to be able sum all values IF the filter is left blank.
=SUMIFS(Data!AX:AX,Data!J:J,B2)
Use an IF function to determine whether the criteria cell is blank, and if it is, use a "regular" SUM function.
Something like,
=IF(B2="",SUM(Data!AX:AX),SUMIFS(Data!AX:AX,Data!J:J,B2))

Excel SumIF with range as Column and Sum range as ROW

I am trying to make this work:
=SUMIF(MATRIX!$B$2:$B$36,"YES",B5:AJ5)
Note that the range is a COLUMN and the sum range is a ROW but when the formula computes it doesn't sum the Row B5:AJ5 it actually sums B5:B40. What do I need to add to have it sum the ROW and not the COLUMN.
EXAMPLE:
As you have discovered, a SUMIF expects both the criteria array and the sum array to be both rows or columns but not one of each. You have correctly used the same number of cells in each; the problem is that they are in different directions. A TRANSPOSE function can reverse the direction that the outer function 'sees' the one of the arrays but you need to change from SUMIF to SUMPRODUCT and enter it as an array formula with Ctrl+Shift+Enter.
=SUMPRODUCT((B$2:B$5="yes")*(TRANSPOSE($H2:$K2)))
When entered correctly with CSE, the result in L2 is 2.3. Fill both right and down for something resembling the following.
I don't believe you can use transpose with SUMIF but someone might know a trick to it.

How do I only count visible (filtered) rows when using the COUNTIFS function? [duplicate]

I've been using Excel's COUNTIFS function to count the number of rows in a table that meet certain criteria, E.g:
=COUNTIFS(Table1[Result],"Fail", Table1[Comments], "")
Now I want to modify this expression so that it only counts rows in Table1 that are visible. (I.E. Not filtered out.) How can I accomplish this?
Simple way is to add another column to table - e.g. called helper with a formula like this
=SUBTOTAL(103, B2)
where column B is Result column
Now change formula to
=COUNTIFS(Table1[Result],"Fail", Table1[Comments], "",Table1[Helper],1)
the subtotal formula only returns 1 on visible rows
Without a helper column you can use this formula
=SUMPRODUCT((Table1[Result]="Fail")*(Table1[Comments]=""),SUBTOTAL(103,OFFSET(Table1[Result],ROW(Table1[Result])-MIN(ROW(Table1[Result])),0,1,1)))
I use this formula:
=subtotal(3,B2:B100)
where subtotal(3, that is CountA and
B2:b100 is the range.
The hidden rows in a filter are ignored and this formula only counts the visible rows.
It works for me and hope it works for you

Total (Sum?) with VLOOKUP

I have my clients on one sheet and their bought items.
On the sheet where I have my client names, I want to have their total.
My code will only "sum" the first cell it encounters that matches the vlookup, it will not add all the cells together matching the vlookup:
=SUM(VLOOKUP([#Customer],Details!B2:F10,5,FALSE))
What I'm trying to achieve is that I get a total of a Customers bought products.
My table looks like this:
Client|Product|Price
------|-------|-----
A |Salade |2
B |Koffee |3.5
A |Apple |0.5
What I want is that I can get sum of A (beeing 2.5), but now I only get the value "2".
I had no luck with SumIF.
=sumproduct((A2:A4="A")*(C2:C4))
That is the formula you basically want. you will need to replace the "A" with your cell reference that holds what you are looking for. Adjust the range of A2:A4 and C2:C4 to match your range. Ensure they are equal in length.
You can read more on SUMPRODUCT here and here
Based on your VLOOKUP formula I would guess your formula would look like:
=SUMPRODUCT((DETAILS!B2:B10=[#Customer])*(DETAILS!F2:F10))
Alternatively you could use the SUMIF formula:
=SUMIF(DETAILS!B2:B10,[#Customer],DETAILS!F2:F10)
SUMIF will check the b2:b10 range for cells matching #Customer's cell value. When a match is found, it will add the corresponding value in the F2:F10 range. Of the two methods it is the preferred method.
If you wind up needing multiple conditions, SUMPRODUCT can be adjusted or you can use SUMIFS.

Resources