SUMIFs in Google sheets with 2 filters on same criteria range - excel

I have looked at various answers but all use filters on different columns. I need an OR type filter like this:
=SUMIFs(B2:B22,C2:C22,"Incurred",C2:C22,"Expected")
Where C2:C22 specifies if the cell in B is an incurred or expected or deferred expense.
How do I do this? Note the filters are on the same set of cells in column C.

This is the data in A6:C6:
1 A C
2 B D
3 A D
4 B C
5 A D
6 B D
To sum the values if column B is A or column C is D you can use:
=SUM(ARRAYFORMULA((IF(((B1:B6="A")+(C1:C6="D"))>0,A1:A6))))
This uses the fact that True equals 1 and False equals 0 once you want to use them in equation.

You may try this...
=SUMPRODUCT(((C2:C22="Incurred")+(C2:C22="Expected")+(C2:C22="Deferred"))*B2:B22)

Related

Ignore text values in subtotal function

Excel-Sheet:
A B C D E
1 1.200
2 Product A 500
3 Product B 400
4 Product C OK
5 Product D #NA
6 Product E 300
7
8
In the above table I have list of products in Column A and some data about the products in Column B.
In Cell B1 I want to calculated the subtotal of Column B using =SUBTOTAL(9,B2:B6).
However, now I have the issue that Column B not only consists of numbers.
It can also have the data type text (OK, NA). Therefore, the result in Cell B1 currently is #NA.
Is there any kind of formula that I could use so only the number data is considered and the result is 1.200 as in the table above?
Please note:
This function =AGGREGATE(9,6,B2:B6) won't help me because I want to filter the list later on so I need to go with the SUBTOTAL.
Use 7 as the second criterion in AGGREGATE instead of 6 as it will also exclude hidden rows:
=AGGREGATE(9,7,B2:B6)
You can solve this, combining the Excel worksheet functions =Value() and =IfERROR():
The function =Value() gives the value of a number, and in case of text it gives an error.
=IfError() can be used to give 0 in that case.
So, imagine you have following situation:
Column A Column B Column C
1 =Value(A1) =IfError(B1;0)
3.5 =Value(A2) =IfError(B2;0)
AB =Value(A3) =IfError(B3;0)
abc10 =Value(A4) =IfError(B4;0)
This gives following results:
Column A Column B Column C
1 1 1
3.5 3.5 3.5
AB #Value 0
abc10 #Value 0
You can simply take the sum of column C.
So this is based on the summary in B1.
=SUM(IF(ISERROR(B2:B6),"",B2:B6))
You need to push Ctrl+Shft+Enter for this to work.
Hope it helps.

VLOOKUP issue in Excel

I have the following basic VLOOKUP setup, having not used Excel in anger for a while. I am looking up the values a, b and C in a table containing two columns.
<value returned> <expected>
a 1 b =VLOOKUP(A1,C$1:D$1,1,FALSE) #N/A #N/A
b 2 c =VLOOKUP(A2,C$2:D$2,1,FALSE) #N/A 2
c 3 d =VLOOKUP(A3,C$3:D$3,1,FALSE) #N/A 3
I am getting #N/A returned for all rows (as shown to the right), but I would expect the values to the right again to be returned. Can someone please explain what I have done wrong?
Thanks
If you still stick to dataset :
a 1 b
b 2 c
c 3 d
then : =INDEX($C$2:$C$4,MATCH(A1,$D$1:$D$3,0))
So if you re-arrange the data as :
a 2 b
b 3 c
c 4 d
then use : =INDEX($C$1:$C$3,MATCH(A1,$D$1:$D$3,0))
hope that helps. (:
When using VLOOKUP, the column containing the key to be matched has to be the first column on the left of the range. So change your data layout to this:
A B C D
a b 1
b c 2
c d 3
and use the following formula:
=VLOOKUP(A1, C$1:D$3, 2, FALSE)
and then it should work. As #Scott mentioned in his comment, if you want to keep your data layout the same, you could look into using INDEX.

Highlight cells based on the value of cells in another column

I have this problem as noted below:
Column A = Part number
Column B = Quantity
Column C = Part number
Column D = Quantity
Using conditional formatting, I would like to highlight if the combination of Part number and Quantity in Column A and B is different to the combination of Part number and Quantity in Column C and D.
Eg:
Col A Col B Col C Col D
1 1111 2 1112 5
2 1112 3 1111 2
3 1131 5 1112 5
4 1122 3 1131 2
To do this, I'd like to set up a couple of 'helper' columns (say E & F) by concatenating Column A & B, C & D.
So essentially, I'd like to take the information from the helper columns E & F, but use conditional formatting to highlight the cell in column B and D.
From the example above, cell B3 and D4 would be highlighted.
Is this possible, and if not, is there are simple alternative? (I don't mind using a macro if need be).
I would use COUNTIFS
For B1:B4
=COUNTIFS($C$1:$C$4,A1,$D$1:$D$4,"<>"&B1)
and for D1:D4
=COUNTIFS($A$1:$A$4,C1,$B$1:$B$4,"<>"&D1)
In case you even want to skip the helper columns, you could format A1 with =$A1&$B1<>$C1&$D1 and copy the format to any cells in you want to be highlighted (even to your helper columns).

Match value based on criteria in two columns

I have the following values in columns A, B and C.
A B C D
3 3 5
4 4 10
In cell D1, how can I find the value in Column C where A=A+1 and B=B+1 i.e. 10?
Are you looking for something like below?
=VLOOKUP(SUM(A1+1,B1+1),C:C,1,FALSE)

How to return multiple values using index/match?

I have the below simple table:
A 1
B 2
C 2
D 1
Using an index/match formula, I have set it up so that it only looks at one row at a time.
However, when I drag this formula down and ask it to return where the second column is a 2. I receive N/A at the top and bottom of my lookup.
Is there a way for me to ask it to skip when there is a NA or return multiple rows?
Here is my code:
=INDEX(B2,MATCH(1,C2))
Which returns:
A 1 A
B 2 #N/A
C 2 #N/A
D 1 D
I would like it to return:
A 1 A
B 2 D
C 2
D 1
So skiiping rows where there is no match.
The easiest way to have it skip what the value is NA is to either put an IF statement
=If(A1 = "NA","",INDEX(MATCH))
or
If it is NA because it is not finding a match
=IFERROR(INDEX(MATCH),"")
one of those 2 should do it. If not please post your code.

Resources