Convert SUMIFS to SUMPRODUCT - excel

This is my SUMIFS which SUM the number in D12:D1000 if the number in E12:E1000 is within 21 to 30.
SUMIFS(D$12:$D$1000,E$12:$E$1000,">20",E$12:$E$1000,"<31")
I tried to convert it to SUMPRODUCT:
SUMPRODUCT(D12:D1000*(E12:E1000=">20")*(E12:E1000="<31"))
But I get 0 as the result. The formula doesn't seem to work.

Your SUMPRODUCT formula should written like this,
=SUMPRODUCT (-- (A2 :A11 >=20),--(A2 :A20<=30),C2 :C20)
Please change data range as you need.

Related

IFERROR formula contain with average and divide function

I am trying to turn those error value to blank but seems the formula below doesn't work.'
=IFERROR(H58-AVERAGE(H20,H24,H16,H12,H35,H47,H43,H39,H8,H31,H54),"")/IFERROR(AVERAGE(H20,H24,H16,H12,H35,H47,H43,H39,H8,H31,H54),"")
The below is the original formula that I let the formula go Value minus average then only go for divide average but some cell still did not contain any formula, then I need to add IFERROR formula to hide the error value in the cell. Anyone can advise a better formula solution on this?
=(D53-AVERAGE(D15,D19,D11,D7,D30,D42,D38,D34,D23,D46))/AVERAGE(D15,D19,D11,D7,D30,D42,D38,D34,D23,D46)
The IFERROR needs to be applied only once. Applying it separately after the divide operation could still result in a number being divided by 0, which would give an error.
=IFERROR((D53-AVERAGE(D15,D19,D11,D7,D30,D42,D38,D34,D23,D46))/AVERAGE(D15,D19,D11,D7,D30,D42,D38,D34,D23,D46), "")
In Ms365 or excel 2021, you can use LET to do the average calculation only once:
=LET(
Avg, AVERAGE(D15, D19, D11, D7, D30, D42, D38, D34, D23, D46),
IFERROR((D53-Avg)/Avg, "")
)

Excel CountIf IsFormula?

Is there a way to calculate the count of items in a range, that are a formula?
I'm only expecting =TEXT formulas, so I tried =COUNTIF(1:1, "=TEXT"), but that didn't work. Seems CountIf only operates with the displayed values of the cells.
If I have understood your post clearly, specifically you need those functions which starts TEXT() then perhaps you could try :
• Formula used in cell F6
=SUM(N(IFERROR(LEFT(FORMULATEXT(D6:D19),6)="=TEXT(",0)))
If you have the following in cells A1:A5
=TEXT("493","DDD")
555
=TEXT("420000","YYYY")
Yep
Nope
Either of these formulas should give a result of 2
Counts formulas
=SUMPRODUCT(--ISFORMULA(A:A))
Counts Cells with Formula Text
=SUMPRODUCT(--ISNUMBER(SEARCH("text(",FORMULATEXT(A:A))))

how can I count number of rows that contains text/numbers in excel

I want to count all rows in a range that contains either text or numbers, what formula can I use for that? I tried this but it does not count correct...
=COUNTIF(B2:B50;"*") + SUMPRODUCT( -- ISTEXT(B2:B50))
data/text in cells can be like this...
S
160
XS
M
To count both text and numbers, use COUNTA > =COUNTA(B2:B50)
Be aware that this does also count empty formulas!
To make your original formulas work.
You can use
=COUNTIF(B2:B50,"<>")
or
=SUMPRODUCT(--(B2:B50<>""))
However, #JvdV formula is more appropriate. If you need to ignore formula blanks then the SUMPRODUCT formula can be used.

Apply a function to an argument inside a formula

How can I apply a function to an argument of a SUMIF or COUNTIF formula?
For example:
=SUMIF(YEAR(B1:B10),"2017", A1:A10)
Where B1:B10 contains an array of dates. For example:
1 A B
2 200 01/01/2017
3 300 01/01/2017
4 420 01/01/2016
5 250 01/01/2016
When I try:
=SUMPRODUCT(A:A*(YEAR(B:B)=2017))
or
=SUMPRODUCT(A1:A5*(YEAR(B1:B5)=2017))
I get #REF! however if I define the ranges like:
=SUMPRODUCT(A2:A5*(YEAR(B2:B5)=2017))
I get the result I expect.
Use SUMPRODUCT with arrays. Multiplying by a boolean array converts it to 0 or 1 array:
=SUMPRODUCT(A1:A10*(YEAR(B1:B10)=2017))
p.s.: this is a valid normal formula, no need for CSE.
On the other hand, SUMIF and SUMIFS want their range arguments to be pure ranges, not arrays.
So it appears that your data is heterogeneous and some cells are not numbers or not dates. To deal with this, try this array formula:
=SUM(IF(ISNUMBER(A1:A5), A1:A5, 0)*(YEAR(IF(ISNUMBER(B1:B5),B1:B5,0))=2017))
Ctrl+Shift+Enter
If you really like the SUMIF then you will need to use SUMIFS and bracket the date:
=SUMIFS(A:A,B:B,">=1/1/2017",B:B,"<=12/31/2017")
You can do the same with COUNTIFS.
No need to use CTRL + SHIFT + ENTER ( CSE )
=SUMPRODUCT(--(TEXT(B7:B10,"YYYY")="2017")*A1:A10)

Passing multiple values to SUMIFS function in Excel

I have Twocolumns A, B ..I am trying to get the sum of A like below.
=SUMIFS(
sheet1!$A:$A,
sheet1!$B:$B, ("AB", "BC", "CD")
)
But this formula is not working.
Please suggest me.
Try to use following formula:
=SUMPRODUCT((sheet1!$B:$B={"AB","BC","CD"})*(sheet1!$A:$A))
or alternatively you can use an array formula:
=SUM(IF(sheet1!$B:$B={"AB","BC","CD"},sheet1!$A:$A,0))
enter formula in the formula bar and press CTRL+SHIFT+ENTER to evaluate it......
If I'm guessing your intention right, you should have:
=SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"AB")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"BC")+SUMIFS(sheet1!$A:$A,Sheet1!$B:$B,"CD")
Add two helper columns: in D:D you have the list of valid values. In C:C you have a formula like this (change ; to ,). In F1 you have your sum like this:
=SUMIFS($A:$A,$C:$C,FALSE)
Now you can add any number of valid criteria in column D:D.
You can use SUMIFS to return an array (one for each criterion) and then SUM to sum those, i.e.
=SUM(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,{"AB","BC","CD"}))
This way retains the speed and efficiency of SUMIFS without needing repetition
If you have your criteria values in a range of cells you can simply reference the range, but use SUMPRODUCT to avoid "array entry"
=SUMPRODUCT(SUMIFS(sheet1!$A:$A,sheet1!$B:$B,Z2:Z4))
where Z2:Z4 contains the criteria
Note: in both of these SUMIFS does all the "heavy lifting" - SUM/SUMPRODUCT is used simply to sum the resulting array

Resources