If cell is true take value from another column - excel

Column A contains some numbers, while column B contains TRUE and FALSE values.
A B
- -
1 TRUE
2 FALSE
3 FALSE
4 TRUE
5 TRUE
In column C, for every TRUE value in column B, take the value in column A in order not the row the TRUE value in in.
For example:
C
-
1
FALSE
FALSE
2
3
When I try to do something like this, all the TRUE values take the number in column A in the row the TRUE value is in.
For example:
C
-
1
FALSE
FALSE
4
5
So, when the desired result is 2 and 3 in the last two TRUE values, the IF formula takes the value from column A in the row the TRUE value is in, which in this case is 4 and 5.
Is there any method to take the value in order if the value in column B is TRUE?

This formula seems to do the trick.
This is my testsheet:
In C2 I have this formula:
=IF(B2="True",1,"False")
In C3 (and drag down):
=IF(B3="True",1+MAX($C$2:C2),"False")

You need another assisting column, let's say D
D should work like this:
if B = true then take A value
if B = false then take previous D value (1 row up)
and then you'd be able to use D for your C - take D value instead of A.

Related

Excel conditon if column a consist in column b

In excel, how can we return true or false in a column based on comparing 2 columns in each cell. for an example
we have a table looks like this in excel
ROW
Column : A | B | C |
1 apple motor
2 pineapple train
3 car plane
4 motor durian
in the given example of the table above.
in column C , first row should return true followed by false. i know we can compare directly using
=if(b1=a4,TRUE,FALSE)
in the first column , this will return true . but i want compare each cell in column b to column a. i have tried this in excel but its returning false instead of true
=if(b1=a1:a4,True,false)
What approach should i use ?
You can use array formula with OR:
=OR(B1=A:A)
Array formula after editing is confirmed by pressing ctrl + shift + enter
Or if you don't want to use an array formula, use COUNTIF:
=COUNTIF(A:A,B1)>0

Excel part II: Take nth value within a sub set

Let me make a second part to another stupid question I can't sort. Imagine we have a list like
Week Value Accept? First
1 a TRUE a
1 b TRUE
1 c FALSE
2 d FALSE
2 e FALSE
2 f TRUE f
3 g FALSE
3 h FALSE
3 i FALSE
4 j FALSE
4 k TRUE k
4 l TRUE
How do I make a formula that outputs the first value within a subset with satisfies a condition.
In rows 2 to 4, it would be B2
In rows 5 to 7, it's B6
In rows 8 to 10 there is no answer: all false.
In rows 11 to 13, it will be B12, ignoring B13 which also is true.
I will appreciate any recommendation, thanks.
Assuming your titles starts in A1
Write in D2 :
{=IF(A1<>A2,INDEX($B$1:$B$100,MATCH(A2&TRUE,$A$1:$A$100&$C$1:$C$100,0))}
the {} shall be inserted by pressing ctrl+shift+enter (array formula)
then extend this formula all the way down. It should give you what you want.
What it does :
IF(A1<>A2,
will only display the result if the cell in the lefthand column is a new week number
INDEX($B$1:$B$100,
will return the n-th value of the column B, where n is :
MATCH(A2&TRUE,$A$1:$A$100&$C$1:$C$100,0)
will return the first line for which the columns A and C concatenated has for value A2&TRUE. It is the reason why you need to use array formula

Using COUNTIFS with a range as criteria

I have a situation where in I have to use COUNTIFS(range1, Criteria1, Range2, Criteria2...), where criteria should be a range in the same excel that has text in it. Is there a way for that?
My actual situation is
Sheet 1 : col A and Col B - Text values
Sheet 2 : Col C and Col D - Text values
For every value in Col A, check if it is there in Col C, the take the corresponding value from Col D and check if it is the same in Col B. I need the count of how many matches or doesn't match. I tried to use Vlookup on this, but couldn't get what I wanted. I appreciate your suggestions on this.
Thanks,
Ramya
The example uses a Named Table.
{=COUNT(IF(([#ColA]=[#ColC])*([#ColD]=[#ColB]),1))}
COUNT method counts the number of values.
([#ColA]=[#ColC])*([#ColD]=[#ColB]) compares the current row's Column A value against Column C value, then returns True/False then the same thing for Column D value against Column B value, and multiplies them together to get:
True
from True * True
or
False
from True * False or False * True or False *False`)
And when the IF statement is True, it returns 1 to be used in the COUNT.
You can use an Array Formula to calculate whether a specific row in a table matches your criteria, then add the ones that do match up.
Ctrl + Shift + Enter to create the Array Formula.

Excel formula or VBA that

I have a worksheet with over 400,000 rows. A is the customer number, B customer name, There may be two or more variations of the Name with the same number. I want to make the names the same relative to the number so in a pivot table there is only one row per customer number. Example of data below.
Column: A,
Customer Number
DEEU9999684
DEEU9999684
DEEU9999684
Column B "Customer Name:"
ZWICKAU-XX
ZWICKAU
ZWICKAU
To make it easier I sorted by customer number, and can use the first instance of the "Customer Name" when then "Customer number" changes and where the number are equal. So the above example all the names can be "ZWICKAU-XX"
I was trying a combination of IF(AND but that obviously doesn't work, example ... =IF(AND(A1=A2, B1=B2, B1, B2)
Hope someone can save me form having to manually scrub 400,000 records.
Thanks, dkmanley
Enter the formula in cell C1: =FALSE (I mean enter text "FALSE" in C1)
and then copy this to column C: =IF(A2=A1;TRUE;FALSE) (Starting from C2)
Enter the formula in cell D1: =A1
Then copy this to column D: =IF(C2=FALSE;B2;D1) (Starting from D2)
Here is a sample:
1 a FALSE a
1 a TRUE a
1 a TRUE a
1 x TRUE a
1 x TRUE a
2 b FALSE b
2 b TRUE b
2 b TRUE b
2 bf TRUE b
2 c TRUE b
2 c TRUE b
3 d FALSE d
3 d TRUE d
3 d TRUE d
3 s TRUE d
3 c TRUE d
3 d TRUE d
3 s TRUE d
4 a FALSE a
4 d TRUE a
4 f TRUE a
4 g TRUE a
4 s TRUE a
4 a TRUE a
You could use something like
=INDEX(B:B,MATCH(A1,A:A,0))
and copy down. The data does not need to be sorted. The formula will return the name for the first occurrence of the number, starting from the top.

When B2=B1 AND C2=C1, return result of 1

I have a spreadsheet sorted by alphabetical order in Column B. I want a formula that yields a '1' in an extra Column E when B2=B1 AND C2=C1.
Column B is Account Name and Column C is state, I am looking for Name/State matches.
In E2 enter:
=--AND(B2=B1,C2=C1)
you can copy this down if required.
You use a combination if IF and AND in the column E cell, as in
=IF(AND(B2=B1, C2=C1), 1, 0)
This will leave either a 1 in column E if they both match properly, or a 0 if not.
You can also use simply =AND(...), but this will leave column E with either TRUE or FALSE.
=(B2=B1)*(C2=C1)
may suit. The elements return TRUE or FALSE and TRUE * TRUE returns 1.

Resources