SUMIFS Formula that would check multiple columns - excel

I have an excel sheet and am attempting to incorporate a SUMIFS formula which would check one column for an condition then check another group of columns to see in the match a condition in order to sum all the values which are > 50000 in the group of columns then multiply those values by 0.084.
My formula returns the #VALUE error. How can I achieve what i want?
A B C D E F G H I
NO 51000 52000 12000 10000 53000
NO 23000 48000 54000 55000 50000
=SUMIFS(E10:I610,A10:A610,"No",E10:I610,">50000")
Help please...

You can switch it to a SUMPRODUCT formula, which can handle the multiple columns:
=SUMPRODUCT(E10:I610*(A10:A610="No")*(E10:I610>50000))
EDIT:
Per JosieP, this will work even if there are text values in the range:
SUMPRODUCT(E10:I610,(A10:A610="No")*(E10:I610>50000))

=SUM(IF(A10:A610="N",1,0)*IF(E10:I610>50000,1,0)*E10:I610)
The above when used as array formula (by pressing ctrl+shift+enter, instead of enter) works too.

Related

Excel printing a specific number in a row subject to other columns

I have an excel file with 3 columns and 100 thousand rows. My goal is to print the number of column A, where the number in column C is the maximum and the number in column B is higher or equal to 0.9. Like this example:
-----+------+-----
A | B | C
-----+------+-----
1 | 0.9 | 130
2 | 0 | 200
3 | 0.95 | 90
In this example for example it should print '1' since column 1 and 3 are higher than 0.9 but 1 is higher than 3 in column C. Anyway to do this in excel?
Assuming your data in column C is positive (or at least, that the maximum value is positive), you can use this array formula:
= INDEX(A:A,MATCH(LARGE(((B:B>=0.9)+0)*(C:C),1),((B:B>=0.9)+0)*(C:C),0))
Note this is an array formula, so you must press Ctrl+Shift+Enter after typing in the formula.
This gets pretty ugly since there is no =MAXIFS() formula. Instead, an array formula will do the trick:
=SUMIFS(A1:A3, C1:C3,MAX(IF(B1:B3>=0.9, C1:C3, 0)), B1:B3,">=.9")
Hit Ctrl+Shift+Enter when entering that so Excel will interpret as an array formula.
The Sumifs() here isn't summing more than one value so no worries there. We are grabbing the value from A1:A3 where C1:C3 is equal to the MAX() of that column where B1:B3 is greater than or equal to .9. Which solves that max() issue. And then we are then only allowing selection A1:A3 where B1:B3 is greater than or equal to .9.
It's not pretty, and it requires us to check that >=.9 condition twice, but it does the job.
Try using this array formula =SUMPRODUCT(INDEX(A2:A20,MATCH(MAX(--($B$2:$B$20>=0.9)*C2:C20),--($B$2:$B$20>=0.9)*C2:C20,0),1)) in cell D2. Confirm it with CTRL+SHIFT+ENTER.
This is the array formula (means you have to click Ctrl + Shift + Enter altogether) what I came up with:
=INDEX(A:C,MATCH(MAX(--(B:B>=0.9)*(C:C)),(B:B>=0.9)*(C:C),0),1)
Please note that I used the whole column but I will suggest to only use the ranges that are needed for faster speed.

How to do a little math in the criteria_range of Countifs Functions (using OR in Countif)

The Excel File is like this
A B
1 0
0 1
1 1
0 1
0 0
1 0
I want to use Countifs function to count how many rows have at least one "1" in any columns, like
=Countifs(A:A+B:B,">=1")
or
=Countifs(or(A:A=1,B:B=1))
I know I can add a Column C, let Column C = Column A + B, and then just count Column C; or I can count the total rows and count rows with "0" in both columns, and then calculate Total Row - Both "0". But in real Scenario, I have more complicated situation, so I prefer not using these two solutions.
Use a SUMPRODUCT function to provide cyclic calculation.
=SUMPRODUCT(--((A1:A6)+(B1:B6)>=1))
SUMPRODUCT does not like trying to calculate text values and full column references slow it down so keep your ranges to a minimum. Using the INDEX function can help isolate a dynamic range of true numbers.
Another solution using array formula:
=SUM(IF(A1:A6=1,1,IF(B1:B6=1,1,0)))
Being an array formula, you'll have to enter this formula by pressing Ctrl+Shift+Enter together.
Use =COUNT(A:A)-COUNTIFS(A:A,0,B:B,0) to count both 0 columns and subtract it from the total rows:
Or you can use:
=COUNTIFS(A:A,1,B:B,1)+COUNTIFS(A:A,0,B:B,1)+COUNTIFS(A:A,1,B:B,0)
if it is not clear what it the total number of rows.

Excel Using SUMIF to sum and select higher numbers

I have the range of figures below
D E
3000 6500
20000 0
15000 0
16000 20000
22000 0
I would like to take the total of column D but add the figures from column E to replace the corresponding value in column D if it exists. For example 3000 would be replaced by 6500 in the top line and 20000 would supersede 16000 in row 4.
I have been taking the sum of column d and manually subtracting D1 and adding E1 and D4 for E4 however as column E may be populated over time I would like not to have to do this over and over again.
Any help on this much appreciated.
An array formula should handle this nicely.
      
The array formula in D2 is,
=SUM(IF(A1:A5>B1:B5, A1:A5, B1:B5))
Array formulas need to be finalized with Ctrl+Shift+Enter↵.
Without array option:
=SUM(E:E)+SUMIF(E:E,0,D:D)
For higher numbers, you might add a column with a formula such as:
=MAX(D2,E2)
and sum that column.

Sum the values of if statements on multiple rows? (Excel)

Say I have a spreadsheet which looks like this:
A B C
1 In Actual Predicted
2 Thing One 300
3 Thing Two 564
4 Thing Three 256 1065
I want to be able to get a sum of the "predicted" column which incorporates values from the "actual" column if the "predicted" value is empty.
I.e. in this case, the value would be 300 + 564 + 1065 = 1929.
I know that I can achieve this for any individual row like so:
IF(C2="",B2,C2)
How do I get a sum of these "if" statements for each individual row?
Thanks.
That can be done with Sumifs() and no helper columns
=SUMIFS(B:B,C:C,"")+SUM(C:C)
Cell D2 = IF(C2="",B2,C2)
Cell D3 = IF(C3="",B3,C3)
...drag / copy to all relevant D cells...
Cell E1 = Sum(D:D)

How to return a value to the left of a table array with VLOOKUP?

I need help searching Column E for value=1 and return the value of column A for the same row. VLOOKUP isn't working because there are many columns being searched and there are several 1's in the lookup, and I couldn't seem to search just 1 column using VLOOKUP. Here's how my spreadsheet looks...
A B C D E
1 Name Weight WeightRank Height HeightRank
2 Mike 170 3 6.3 2
3 Richard 200 1 6.0 3
4 Charles 185 2 7.0 1
So I want to search column E for value=1 and return the corresponding value in column A, which in this example would search "HeightRank" for "value=1" and return "Charles"
I tried using =VLOOKUP(1,E:E,1) but that returns an error.
I tried using =VLOOKUP(1,A1:E3,1) but that returns an error.
INDEX(A:A,MATCH(1,E:E,0))
VLOOKUP doesn't work here -- it always searches in the first column of your table and returns a value of a column a given number of columns to the right.
The INDEX/MATCH combination is more flexible, letting you just choose the two columns you want. It's also easier to read (you don't have to count columns to see what it does) and it doesn't break if you insert or delete columns in between the ones you're using, which VLOOKUP does. If you use the trace-formula features, VLOOKUP also falsely implies that all the columns in between are precedents of your resulting formula. (Can you tell that I don't much like VLOOKUP? I just always use INDEX/MATCH and my life is easier for it.)
The OFFSET solution works but it's volatile, so you'll really bog down your worksheet if many cells depend on the result of your formula.
MATCH(x,E2:E4,0) returns the relative position of x in the range E2:E4. For example, MATCH(1,E2:E4,0) returns 3, because 1 is the value of the third cell in the range E2:E4.
OFFSET(A2,r,c) returns the cell r rows and c columns away from A2.
Thus you can say =OFFSET(A2,MATCH(1,E2:E4,0)-1,0) to return the value from column A corresponding to the cell in column E that contains 1.

Resources