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...
Related
Given an Excel table of shape
Col. A Col B Col. C Col. D Col. E
x 2 x 2 3
x 3 y 7
y 7 z -5
x 2
z -5
I want to return the first unique hit in Column B for argument "x" in Column D,
the second unique hit in Column B for argument "x" in Column E and so forth.
The formula I'm currently using in cell D1 for this is
{=IFERROR(INDEX($B$1:$B$5,MATCH(0,COUNTIF($C1:C1,$B$1:$B$5)+($A$1:$A$5<>$C1),0)),"")}
which is working.
The problem I'm having is that since this is an array formula and since I'm analyzing a decent amount of data computation time for my sheet is too high.
Is there an alternative for this functionality avoiding an array formula?
Thanks!
Haven't got time to test this properly, but if you have Excel 365 you can use a single formula per row and it may be faster:
=TRANSPOSE(UNIQUE(FILTER(B1:B10,A1:A10=C1)))
in D1.
EDIT
To pull the formula down, you need static references as OP has pointed out. Probably should check for empty cells in column C as well, so formula becomes:
=IF(C1="","",TRANSPOSE(UNIQUE(FILTER(B$1:B$10,A$1:A$10=C1))))
F1:N1 with random numbers (can have duplicates).
F2:N2 with sorted numbers.
Need a formula to fill in A1:C1 with values from F2:N2 where F1:N1 has a maximum value.
In the example it should be 1,8,3 from F2:N2 - according to 9,9,8 from F1:N1.
_ A B C D E F G H I J K L M N
1 ? ? ? 9 3 8 1 5 5 3 9 8
2 1 2 3 4 5 6 7 8 9
You can do this with a "helper row" to create a list of unique ranks:
F3: =RANK(F1,$F$1:$N$1)+COUNTIF($F$1:F1,F1)-1
and fill right to N3
Since your values in F2:N2 are sequential {1...8}, you can use this formula:
A1: =MATCH(SMALL($F$3:$N$3,COLUMNS($A:A)),$F$3:$N$3,0)
and fill right to C1
If the values in F2:N2 are random, then you can use this:
A1: =INDEX($F$2:$N$2,1,MATCH(SMALL($F$3:$N$3,COLUMNS($A:A)),$F$3:$N$3,0))
and fill right to C1
Nobody has jumped in to offer a Google Sheets solution so here is one:
=query(transpose(sortn(transpose(F1:N2),3,,1,false,2,true)),"select Col1,Col2,Col3 limit 1 offset 1")
In A1. This is a self-expanding formula so does not need to be filled across and does not need helper rows.
EDIT
'Limit 1' may be omitted in the above formula as mentioned in the comment.
Also this is a little shorter:
=transpose(query(sortn(transpose(F1:N2),3,,1,false,2,true),"Select Col2"))
Formula in A1 = INDEX($F$2:$N$2,MATCH(COLUMN(A1),$F$3:$N$3,0)) and is dragged till C1
Formula in F3 = RANK(F1,$F$1:$N$1)+COUNTIF($F$1:F1,F1)-1 and is dragged till N3
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),"")
I have the following table:
Sheet 'raw':
Account | Value
A 2
A 3
B 5
C 2
A 1
B 4
D 8
F 18
D 4
What I would like to capture the top n accounts by sum of values using only Excel formulas:
Sheet2:
Top | Account | Sum
1 F 18
2 D 12
3 B 9
4 A 6
4 C 2
I tried this approach (considering A to C columns in Excel):
- for the value:
{=LARGE(ROUND(raw!B$2:B$65000,2)+ROW(raw!B$2:B$65000)/10000),A2)}
for the account name:
{=INDEX(raw!$A$2:$A$65000,MATCH(A2,(ROUND(raw!B$2:B$65000,2)+ROW(raw!B$2:B$65000)/10000),0))}
I use array formulas for that, but it will provide me the top individual values not the sum per account
Could someone help me on this topic?
Thank you in advance!
With your dataset following seems to work:
In cell C2, CTRL+SHIFT+ENTER and not just ENTER following formula:
=LARGE((ROW(Sheet1!$A$2:$A$10)=MATCH(Sheet1!$A$2:$A$10,Sheet1!$A$1:$A$10,0))*SUMIF(Sheet1!$A$2:$A$10,Sheet1!$A$2:$A$10,Sheet1!$B$2:$B$10),ROWS($C$2:$C2))
In cell B2, CTRL+SHIFT+ENTER and not just ENTER following formula:
=INDEX(Sheet1!$A$2:$A$10,MATCH(Sheet2!C2,(ROW(Sheet1!$A$2:$A$10)=MATCH(Sheet1!$A$2:$A$10,Sheet1!$A$1:$A$10,0))*SUMIF(Sheet1!$A$2:$A$10,Sheet1!$A$2:$A$10,Sheet1!$B$2:$B$10),0))
Edit: There's typo in the formula Sheet2!D2 should be Sheet2!C2.Above formula is corrected.
CAUTION: Formula may give incorrect results if totals tie.
I have three columns
A B C
Slots Remarks Amount
10 x must be zero (coz amount got formula [slot*100])
20 / 2,000 [answer for 20slots x 100]
10 / 1,000
5 x -
That's why I think of conditional formatting.
TQ
In C2 use the following formula and copy down
=IF(B2="","",A2*100)
or
=IF(B2="",0,A2*100)
Update for checking for x in column b
If you want to to have 0 or blank, check to see if B2="x"
=IF(B2="x","",A2*100)
or
=IF(B2="x",0,A2*100)