conditional formating IF column b is empty then column c will be no value or zero - excel-formula

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)

Related

Return Multiple Unique Matches in Excel without Array Formula

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

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

Populate summary "table" column based on details "table"

I've tried looking up how this might be done, but it's a bit beyond my excel-fu, unfortunately (I could do it in SQL in a snap!).
Basically, in one worksheet, I have the following details "table" (I've included the column and row labels):
A B C D
1 owner name line # run?
2 A A1 10 Y
3 A A1 20 N
4 A A2 2 Y
5 A A2 14 Y
6 A A3 34 N
7 B B1 26 Y
8 B B1 59 Y
9 B B1 193 Y
10 B B1 194 Y
11 B B2 27 N
12 B B2 51 N
and I have the following summary "table" on a different worksheet
A B C
1 owner name status
2 A A1
3 A A2
4 A A3
5 B B1
5 B B2
I need to populate the status column in the summary "table" based on the run? column in the details "table", linked on the owner and name columns.
Here are the results I'm expecting to get, along with why:
A B C D
1 owner name expected status reason
2 A A1 Partial There are Y and N values for owner=A and name=A1 in the details table
3 A A2 Complete There are only Y values for the owner=A and name=A2 in the details table
4 A A3 Not Started There are only N values for the owner=A and name=A3 in the details table
5 B B1 Complete There are only Y values for the owner=B and name=B1 in the details table
5 B B2 Not Started There are only N values for the owner=B and name=B2 in the details table
I know I'll probably need countifs to work out if there are Y's and N's present, plus an IF to turn the output into the words, it's the getting to the point where I can count the Y's and N's present for each owner+name that I'm struggling with.
I have googled how I might find out if there were Y's and/or N's present for a given owner and name, and have come across this link which involves MATCH and INDEX but for the life of me, I can't get it working - I get an output of #N/A, using the following formula to get the first status:
=INDEX(A2:D12,0,MATCH(c2,'<Detail worksheet>'!A2:D12,0))
Am I on the right lines or is there a better way of doing this? (I could always manually specify the range of rows to look down in the details "table" for each summary "table" row, but I'd like to avoid that if possible!)
I split the formula into two parts, which should get you most of the way there. If you have an uncertain length of data, then be careful with how many rows you examine, my answer only goes to row 13.
Summary Sheet with columns added to split formula
Sheet 1
The formula for the Y column in the above picture is:
=COUNTIFS(Sheet1!$E$3:$E$13,Sheet2!$D$2,Sheet1!$B$3:$B$13,Sheet2!$B3,Sheet1!$C$3:$C$13,Sheet2!$C3)

Google Sheets - formula to return N first values from range A where MAX(range B)

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

Contruct cumulative sum for duplicates

I am looking for formula in Excel to construct cumulative sum for the duplicates.
Item Value Cumulative sum
-----------------------------
A 3 3
A1 4 4
A1 7 11
A1 5 16
B1 20 20
B1 4 24
C 6 6
D 10 10
E 8 8
E 7 15
The table given shows the cumulative for the duplicates in Column 1(Item).
I need excel formula to construct this for my calculations.
Break problems like these down step-by-step.
(Assume your data are in A1:C11 (col C is empty except for the header).)
To calculate a cumulative sum, you just add the current value in col B to the previous value in col C. This is simply =C1+B2 in C2, =C2+B3 in C3, etc.
To evaluate whether you are in the same group of Item, you can simply test whether A2=A1, A3=A2, etc.
To reset your cumulative sum when the group changes, you can use an IF() function. In (2), you have a logical condition. In (1), you have an operation to perform if the condition is true. If the condition is not true, you want to reset the cumulative sum, which is simply the value of col B in the current row.
So to put it together (in C2):
=IF(A2=A1, C1+B2, B2)
Then fill down.

Resources