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.
Related
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.
I cant fix my formula. Or better i dont even know if im on right way.
My geal is: row B is empty, there will be formula.
A B C D
1 ID TYPE ID_Criteria
2 1 FIRM 4
3 0 HUMAN
4 3 FIRM
5 4 CORPORATE
IF A2 > 0 then VLOOKUP in row D, if false B2 is FIRM. Otherwise IF A2 > 0 then VLOOKUP in row D and TRUE B2 is CORPORATE. And last condition when A2 < 0, row return Human.
My formula:
=IF(A2>0,IF((VLOOKUP(A2,D1:D4,1,0),"CORPORAT","FIRM"),"HUMAN"))
Any ideas ?
Use
=IF(A2>0,IF(ISNUMBER(MATCH(A2,$D$1:$D$4,0)),"CORPORATE","FIRM"),"HUMAN")
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
In my excel sheet I have 3 columns as :
A B C
===================
XYZ N 9
ABC N 1
MNO N 3
D 13
D D 7
D D 9
D 1
Now, From these sheet I want sum of all cells in C column where either value in A or B column's cell is 'D'.
something like : if(a='D' or b='D') then sum+=C
Here, for case SUM(where cell value is 'D' in columns A or B) will be 30.
Let's say you had those values in cells A1:C7, this should do the trick:
=SUMPRODUCT(C1:C7*(A1:A7="D"))+SUMPRODUCT(C1:C7*(B1:B7="D"))-SUMPRODUCT(C1:C7*(A1:A7="D")*(B1:B7="D"))
To explain the formula, it is:
(Sum of C where A = "D") + (Sum of C where B = "D") - (Sum of C where both A = "D" and B = "D")
The reason for the last part is to avoid double counting.
I want to compare column A in sheet 1 with column A in sheet 2, and only return matches from sheet 2.
I then, want to use the matching column A rows as a basis for a second comparison. The second comparison is to compare column B in sheet 1 with column B in sheet 2 and only return non matches from sheet 2.
Assume this is the data on sheet 1:
A B
2 4
2 4
2 3
3 3
and this is the data on sheet 2:
A B
2 4
3 3
2 4
3 3
So, only the third row will pass on both conditions. Any ideas how this can be done?
I want to compare column A in sheet 1 with column A in sheet 2 and only return matches from sheet 2
Type on cell C1, on sheet 1:
=IF(A1=Sheet2!A1,"True","")
Drag the formula to all rows on column A, which contain non blank cells.
The second comparison is to compare column B in sheet 1 with column B in sheet 2 and only return non matches from sheet 2.
Type on cell D1, on Sheet 1:
=IF(AND(C1="True",B1<>Sheet2!B1),"True","")
Drag the formula down.
Output on Sheet 1 should be like that:
A B C D
2 4 True
2 4
2 3 True True
3 3 True
Filter column C by True to observe the "first" condition's returns. Do the same to column D to retrieve the data which satisfies the "second" condition.