Filter a table to return a value - excel

Let imagine, we have this table from column A to C
A
B
C
Date
Name
Price
10/01/2020
aa
5
10/01/2020
bb
5
15/01/2020
aa
5
Now I have two lines :
F
G
H
12/01/2020
aa
?
16/01/2020
aa
?
How can I automatically fill the "?" next to the two lines ?
There is two criteria :
column G must match column B (easy with INDEX and MATCH)
select the dates larger than F and finally, the smallest date.

Formula for H1 is
=SUMIFS($C$2:$C$4,$A$2:$A$4,MINIFS($A$2:$A$4,$A$2:$A$4,">="&F1,$B$2:$B$4,G1),$B$2:$B$4,G1)
Then copy to H2. It returns 0 for H2 since 16/01/20 is greater than all of the dates in column A.

With Office 365 dynamic arrays:
=#SORTBY(FILTER($C$2:$C$5,($A$2:$A$5>F1)*($B$2:$B$5=G1),""),FILTER($A$2:$A$5,($A$2:$A$5>F1)*($B$2:$B$5=G1),""))
If one has LET() it can be shortened to:
=LET(dt,$A$2:$A$5,x,(dt>F1)*($B$2:$B$5=G1),#SORTBY(FILTER($C$2:$C$5,x,""),FILTER(dt,x,"")))

Related

Count unique values in excel based on multiple criteria

I've got a spreadsheet with 3 columns and want a formula to count the unique values in column A based on 3 criteria against B and C.
Below is an example of the data and desired output. E2:H2 is where the formula should go. The data contains blank values in column C. Column B is the result of a vlookup.
A B C D E F G H
1 Email List Date 1/1/19 1/2/19 1/3/19 1/4/19
2 1#1.com X 1/1/19 2 1 1 0
3 2#2.com Y 6/3/19
4 3#3.com Z 2/2/18
5 1#1.com X 9/1/19
6 4#4.com X 5/2/19
7 1#1.com X
8 5#5.com X 4/1/19
9 4#4.com X 3/2/19
10 5#5.com X 4/3/19
I want to find the number of unique values in column A where column B == X and column C falls within a particular month (provided by E1:H1).
I'd like to avoid using multiple pivot tables for each date range if possible.
I've tried two formulas which don't work.
{=SUM(IF((B2:B10="X")*(C2:C10>=E$1)*(C2:C10<F$1), 1 / COUNTIFS(B2:B10, "X", C2:C10, ">="&E$1, C2:C10, "<"&F$1, A2:A10, A3:A10)), 0)}
=SUMPRODUCT(((B2:B10="X")*(C2:C10>=E$1)*(C2:C10<F$1)) / (COUNTIFS(A:A, A2:A10, B2:B10, "X", C2:C10, ">="&E$1, C2:C10, "<"&F$1)))
I've seen similar questions in Stack Overflow but none worked for me.
Any help appreciated.
You could implement some BOOLEAN logic and check if MONTH and YEAR in C:C are the same as the lookup month and multiply that against your "x" criteria in column B:B:
Formula in E2:
=SUM(--(FREQUENCY(IF((MONTH($C$2:$C$10)=MONTH(E1))*(YEAR($C$2:$C$10)=YEAR(E1))*($B$2:$B$10="X"),MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1)>0))
Note: It's an array formula and needs to be confirmed through CtrlShiftEnter
Drag right...

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),"")

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).

SUMIF a cell on the same row, in a certain column, contains a specific text

I'm trying to sum all transactions on a spreadsheet of my bank statement. Let's say I have the following under columns B-F:
B C D E F G
Date Type Transaction Value Balance ???
row 4 23/05/14 BAC Bank transfer A 1103.55 637.03
row 5 23/05/14 POS Pizza purchase 10.00 627.03
row 6 23/05/14 POS Coffee purchase 10.00 627.03
I'd like to make a new cell on column G which sums all values in column E that are on rows containing "POS" in column C. Is this possible?
Yes and I believe the simplest way is by using SUMIF:
=SUMIF(C:C, "POS", E:E)
In other words, sum E:E if C:C equals "POS".
=SUM(IF(C4:C6="POS",1,0)*E4:E6) is one way. Expand the ranges to taste.
Note this is an array formula: you need to press Ctrl + Shift + Return once you're done editing.

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.

Resources