Excel comparing value from row to different columns - excel

I have a Table like this in Sheet1
A B
1234.jpg | c1
1234.jpg | c2
1234.jpg | c3
3456.jpg | c8
3456.jpg | c9
3456.jpg | c10
haha.jpg | c2
haha.jpg | c5
haha.jpg | c9
I need the to match the data according to the Columns in Sheet2 and the data should result something like this.
c1 c2 c3 c4 c5
123.jpg Y Y Y N N
3456.jpg N N N N N
haha.jpg N Y N N Y
I am currently only able to make out this
=IF(ISERROR(MATCH(A2,Sheet1!$A$1:$B$9,0)),"Y","N")
Which returns Y as long as A2 matches something from the array. How do I go about matching it as the Column in Sheet2? I'm open to using functions or VBA

Use following formula to D3 cell as per screenshot.
=IF(SUMPRODUCT(($A$2:$A$10=$C3)*($B$2:$B$10=D$2))=1,"Y","N")
....................................................................................................................................................... You can also use this array formula.
=IF(ISNUMBER(MATCH($C3&D$2,$A$2:$A$10&$B$2:$B$10,0)),"Y","N")
Press CTRL+SHIFT+ENTER to evaluate the formula as it is an array formula.
After entering formula as array formula, drag and drop to right and down as you need.

Related

Pivot table generating custom value by comparing the 2 column's

I have below table.
Identity_No Date1 Date2
123 1/6/2018
456 4/7/2018 8/8/2018
567 10/10/2018 6/12/2018
now i need to generate a table like below
Identity_No 1/6/2018 4/7/2018 8/8/2018 10/10/2018 6/12/2018
123 y n n n n
456 n y y n n
567 n n n y y
please let me know how to create it with pivot function or any other option.
you can achieve this with combination of formulas(if your data structure is as presented). If your values are in range A1:C4, please enter this formula in cell G1 and drag it to the right. You must enter this formula with CTRL+SHIFT+ENTER combination since it is an array formula.
=NUMBERVALUE(INDIRECT(TEXT(MIN(IF(($B$2:$D$9<>"")*(COUNTIF($F$1:F1,$B$2:$D$9)=0),ROW(2:9)*100+COLUMN($B:$D),7^8)),"R0C00"),)&"")
This way you will extract unique dates from your range of dates in B:C columns.
then in cell f2 enter formula =A2 and drag it to the bottom. In cell G2 enter this formula =IF(IFNA(MATCH(G$1,$B2:$E2,0),"n")="n","n","y") and drag it beneath whole table.

Add A1 to C1 if B1 = Specific Number

I will try to be as clear and concise as possible. I am working on a spreadsheet in which I have item prices listed in a range of A1:A40. B1:B40 lists a numerical digit (either 1, 2, 3, etc.) that corresponds with a purchase category type (groceries, gas, etc.). Now I want one cell, such as C1, to add all instances in the A range that equal a specific number in B.
For example:
A1 = $5.00 | B1 = 1 | C1 = The sum in range A1:A3 if it's corresponding B value is equal to 1 (In this case B1 and B3, so C1=A1+A3)
A2 = $2.50 | B2 = 2 | C2 = The sum in range A1:A3 if it's corresponding B value is equal to 2 (In this case B2, so C2= B2)
A3 = $4.00 | B3 = 1 | C3 =
Use SUMIF Function
SUMIF(range, criteria, [sum_range])
In Cell C1 enter the formula = SUMIF(B:B,1,A:A)

Sum fields in a column if there is an entry in a corresponding row in another column

Assume the following data:
| A B C
--+------------------------
1 | 2 3 5
2 | 2 3
3 | 4 4
4 | 2 3
5 | 5 6
In cell A6, I want Excel to add cells C1, C2, C3 on the basis that A1, A2 and A3 have data in. Similarly, I want B6 to add together C1, C4 and C5 because B1, B4 and B5 have data.
Can someone help?
In A6 enter:
=SUMPRODUCT(($C1:$C5)*(A1:A5<>""))
and then copy to B6:
A simple SUMIF formula will work
=SUMIF(A$1:A$5,"<>",$C$1:$C$5)
Place that formula is cell A6 and then copy it to B6.
You can create another column, e.g. AValue, with the formula =IF(ISBLANK(A1),0,A1) in it. This will return 0 if the cell in A in the corresponding line is empty, or the value from the cell in A otherwise.
Then you can just sum up the values of the new column.

Excel: Given a cell in column B as input, how could I find out the lowest cell of A which B > A?

I have an excel sheet, which value of column A >= B in the same row.
I would like to know given a cell in column B, how could I find out the lowest cell of A which B > A? (It should return a cell address but not the value)
For example, the following shows cells from A1 to B7 in a sheet:
A B
------
1 | 1 1
2 | 3 2
3 | 5 3
4 | 7 4
5 | 9 5
6 | 10 6
7 | 15 10
Now I would like to input B6, then it should return A3 (since 6 > 5)
Another example, if I input B7, then it should return A5 (since 10 > 9)
Is there any approach (or similar approach) by using excel formula? Or should I use other methods?
If your input value is in cell E1, and your return value is in cell E2 (as shown in below image), then you can use this formula in cell E2:
=IF(E1="","",INDEX(A1:A7,MAX(1,MATCH(TRUE,INDEX(A1:A7>=E1,),0)-1)))
Input Cell E1 (enter the address from column B here)
F1: =ADDRESS(LOOKUP(2,1/(INDIRECT(E1)>ColA),ROW(ColA)),1,4)
Given your data, if you enter B6 in E1, A3 will show in F1

Logical calculation in Excel

I need advice/help. I am working on calculation in excel where I have data like mentioned below.
. A B C D E F G H
1| A275 A277 A273 A777 A777 TOTAL A222 GRAND TOTAL
2| 5 7 4 3 4 7 7
Now, I want to count row 2 based on the header.
Here is the condition.
If A1 <> B1 then take A1, if B1 <> C1 then take B1, if C1 <> D1 then C1, so on.
But tricky part is...
If D1<>E1 then D1 else (if E1<>F1 then E1 else (if F1 = "TOTAL" then F1 else(if F1<>G1 then F1)))
In short H2 should have 30 and not 37.
Added comments:------------------------------------
So, Basically if A1<>B1 then take A1 but if A1=B1 then take B1, but then for B1, its a same rule like if B1<>C1 then take B1, but if B1=C1 then take C1 and for C1, same rule. Stopping point will be "TOTAL". Along with these logic I need to check if any cell in row 1 is "TOTAL" then take value for same column. Now this "TOTAL" can be in any cell in row 1.
So from above table my calculation will be 5(A2) + 7(B2) + 4(C2) + 7(F2) + 7(G2) = 30
In this calculation I have not included D2 and E2 as D2=E2 so I took D2, here E2<>F2 so I should have taken E2, but as F2="TOTAL" so I took F2 and not D2 and E2.
I hope this make sense. (Sorry, I know its confusing.)
I have data in more then 100 columns.
Can this be achieved using Macro?
------------------------------------------------------------
Another pain point is data and header are dynamic, so I can't have a fix format. Logic should be in a way that can handle the dynamic data and header.
Any help or suggestion will be greatly appreciated.
I achieved the results you want with this.
Add a helper row. In cell A3 write this formula and drag it to the right:
=IF(OR(A$1=B$1,B$1="TOTAL"),0,1)
Calculate sum in say cell H4 (not H2 because if the formula refers to entire row 2 there will be circular reference):
=SUMIF($3:$3,1,$2:$2)

Resources