SUM cell values based on multiple condition - either A column or B column cell is true. Any of the two. But not always both conditions are true - excel

In my excel sheet I have 3 columns as :
A B C
===================
XYZ N 9
ABC N 1
MNO N 3
D 13
D D 7
D D 9
D 1
Now, From these sheet I want sum of all cells in C column where either value in A or B column's cell is 'D'.
something like : if(a='D' or b='D') then sum+=C
Here, for case SUM(where cell value is 'D' in columns A or B) will be 30.

Let's say you had those values in cells A1:C7, this should do the trick:
=SUMPRODUCT(C1:C7*(A1:A7="D"))+SUMPRODUCT(C1:C7*(B1:B7="D"))-SUMPRODUCT(C1:C7*(A1:A7="D")*(B1:B7="D"))
To explain the formula, it is:
(Sum of C where A = "D") + (Sum of C where B = "D") - (Sum of C where both A = "D" and B = "D")
The reason for the last part is to avoid double counting.

Related

scan Excel column based on another column value

I want to check one entire column with value in another column and then assign a value in another column value to matching row cell.
Eg-
A B C D
1 10 X
2 3 Y
3 2 Z
4 11 K
What I want to do is take one value at a time from column A eg 1 and then scan through Column B if matches the Column A (value 1) then assign x to that row under D. eg if we check A3 ( value 2) with column B and found 2 is on B4 then D4 = Z. Like this I want to check all values in column in A against column B assign relevant vale from column C to Column D
How can I do this, can someone please help me.
Thanks.
Try:
= IFERROR(INDEX($C$2:$C$5,MATCH(A3,$B$2:$B$5,0)),"no match")
See below.
Try:
=IFERROR(VLOOKUP(A1,$B$1:$C$5,2,0),"")

Searching cell values in next cell

Column1 Column2 Column3 Column4
A 4573925208184160 4630 I
B 4573925208184800 4460 C
C 4573925208184260 4800 F
D 4573925208184460 3970 B
E 4573925208184730 4230 G
F 4573925208184180 4260 J
G 4573925208184440 4730 K
H 4573925208184150 4850 M
I 4573925208184230 4160 E
J 4573925208183970 4180 D
K 4573925208184630 4440 A
L 4573925208184550 4390 N
M 4573925208184850 4150 H
N 4573925208184390 4550 L
I am new in excel tool and want to find last 4 digits of column2 in column3. If found then want to show column1 value in column4.
Let's see: for first row, last 4 digits of column2 value is '4160'. It is present in front of I. So column4 value is I.
A simple INDEX/MATCH function pair should so, providing you use the RIGHT function to peel off the right 4 digits from the longer number in column B.
=INDEX(A:A, MATCH(--RIGHT(B1, 4),C:C, 0))
Fill down as necessary.
    
Place this formula in column 4:
=INDEX($A$2:$A$15,MATCH(VALUE(RIGHT(B2,4)),$C$2:$C$15,0))
The formula assumes your data starts in cell A1 with the column 1 - 4 as headers.
The Index function will return the corresponding value in Column 1 for the Match of the Right 4 most characters for the value in column 2 against the values in column 3.

Compare 2 Columns values in 2 ExcelSheet

I want to compare two columns in excel 2 sheets
In sheet A Column is Gender with Numeric Value
And in sheet B Column is Gender with Alpha Value
A Gender B Gender
----------------------
1 M
2 F
2 F
1 M
2 M
1 F
Here 1 = M and 2 = F.
If A Gender is 1 and B Gender is M then correct.
If A Gender is 1 and B Gender is F then Wrong.
How to Compare the Value in Excel?
Assuming Gender data starts from A2 and goes down, type the following formula in C2:
=IF(OR(AND(A2=1,B2="M"),AND(A2=2,B2="F")),"OK","WRONG")
and autofill down as required.
Another alternative formula which might be easier to understand (and extend values if needs be)...
=CHOOSE(A2,"M","F")=B2
This formula basically reevaluates column A to be "M" when 1 and "F" when 2. Then asks if that equals Column B, and you get a TRUE/FALSE return ;)
If you have a third value for 3, just add another comma separated value onto the end of the CHOOSE function.

Excel get average of a result of index+match function, see details

So I have:
A B C down here i want to get an average
like this:
v 1 a (*1) filter col "C" for what i have in row for col C, in this case "a", then filter col A for what I have in my row for col A, then all those rows must be counted, then sum them and then: sum/count
v 2 a
y 3 a
y 7 a
y 3 a
v 2 b
y 4 b
v 2 b
y 7 b
thanks
You want COUNTIFS and SUMIFS (check Excel help for the params)
Assuming your first row starts on A1:
=SUMIFS($B$1:$B$9,$C$1:$C$9,C1,$A$1:$A$9,A1) / COUNTIFS($C$1:$C$9,C1,$A$1:$A$9,A1)

how to get such results using excel formula

i have two excel sheets
An example of the two sheets are below
sheet1
a 1
b 2
d 1
e 3
g 1
sheet2
a
b
c
d
e
f
i want to put a formula in b1 of sheet 2 and drag it down so that the resulting sheet 2 is
sheet2
a 1
b 2
c 0
d 1
e 3
f 0
explanation : - a = 1 because same value in book1
b = 2 because same value in book1
c = 0 because c does not exist in book1
d = 1 because same value in book1
e = 3 because same value in book1
f = 0 because f does not exist in book1
what formula can i use in b column of sheet 2 ?
A combination of if(), iserror() and vlookup() will be your best bet here.
Assuming your data from sheet1 is in a range called 'refdata',
=IF(ISERROR(VLOOKUP(A1,refdata,2,FALSE)),0,VLOOKUP(A1,refdata,2,FALSE))
should do what you need (Where A1 is the cell containing the data you want to match on)
In Excel 2007 it looks like this:
=IFERROR(VLOOKUP(A1,sheet1data,2,0),)

Resources