I need to search for the row number for the first occurrence of a blank cell if conditions are met. In the first column, it will need to find a 'T' and then in the 'Answer' column, a blank cell.
=MIN(IF(ExamTbl[UnLockedField]="T",IF(ExamTbl[Answer]="",ROW(ExamTbl[Answer])-ROW(ExamTbl[#Headers]),0)))
The formula I used just returns a 0 but in the picture, I am expecting 15 as that is the first blank cell that matches against a 'T'.
I have created following Excel sheet:
A B C D
1 H a
2 H <BLANK>
3 H <BLANK>
4 T b
5 T <BLANK>
6 T <BLANK>
7 H c
8 H d
In C1:C8, I've put following formula:
=IF(AND(A1="T",ISBLANK(B1)),1,0)
In D1, I've put the formula:
=MATCH(MAX(C1:C8),C1:C8,0)
In other words:
In column "C" I put a 1 if both "A" column value is "T" and "B" column value is blank.
In column "D" I look for the maximum value in "C" column (being 1) and ask for the first match, using exact match (hence the zero at the end).
So my sheet becomes (values):
A B C D
1 H a 0 5
2 H <BLANK> 0
3 H <BLANK> 0
4 T b 0
5 T <BLANK> 1
6 T <BLANK> 1
7 H c 0
8 H d 0
The 5 in "D1" is what you are looking for.
Related
Imagine 3 columns, Column A and Column B and Column C.
Column A is a date column.
Column C is lookup column that looks up a value from 1 - 100 from a different table based on the date.
Column B is continuation of values from 0 from the first date value and continues with the value until the value in column c changes.
How do you formulate column B so it automatically keeps the last non zero value until another value in column C appears?
Column A
Column B
Column C
01/01/2021
0
0
02/01/2021
0
0
03/01/2021
0
0
04/01/2021
20
20
05/01/2021
20
0
06/01/2021
20
0
07/01/2021
50
50
08/01/2021
50
0
09/01/2021
50
0
Either
=IFERROR(LOOKUP(2,1/(C$1:C1<>0),C$1:C1),0)
Or;
=XLOOKUP(TRUE,C$1:C1<>0,C$1:C1,0,0,-1)
Or, if these values are always bigger then the last one:
=MAX(C$1:C1)
You can do it as a spill formula in Excel 365 too:
=LET(range,C1:C9,
seq,SEQUENCE(ROWS(range)),
XLOOKUP(seq,IF(range>0,seq),range,0,-1)
)
I have two sheets in excel. Sheet1 has A, B, C and D columns. Sheet2: A, B, E as columns. I want compare Sheet1 and Sheet2 columns (A&B) and write C from Sheet1 only if A&B in both sheets matches.
Eg:
Sheet1
A B C D
Sheet2
A B E
Add column C in Sheet2 only if A&B columns in both sheets matches
You can use vlookup function.
In Sheet1 you need to make a new column consisting of a and b at the beginning, for example:
Sheet1:
A B C
1 2 a
2 3 b
4 6 c
Sheet1 after changes:
new_column_A old_A B C
12 1 2 a
23 2 3 b
46 4 6 c
New_column_A can be created using formula =old_A1&B1
If you have this in your Sheet1 you can use vlookup function in your Sheet2 in column C to look for the values from Sheet1.
Sheet2
A B C
2 3 b
1 3 #N/D!
4 6 c
5 8 #N/D!
Your formula for C column would look like that:
=VLOOKUP(A1&B1,Sheet1!$A$1:$D$4,4,0)
If you don't want the #N/D! values you need to add IF condition:
=IF(ISERROR(VLOOKUP(A1&B1,Sheet1!$A$1:$D$4,4,0))=TRUE,"",VLOOKUP(A1&B1,Sheet!$A$1:$D$4,4,0))
Result:
A B C
2 3 b
1 3
4 6 c
5 8
I have a data set like this:
a 1 2 3 5 6 7
b 5 1 3 4
c 7 4 3 2 6
d 1 2 3 7
e 7 5 5 6 7
which i want to transform in excel to only show the last 4 numeric values for each row, i.e.
a 3 5 6 7
b 5 1 3 4
c 4 3 2 6
d 1 2 3 7
e 5 5 6 7
Ive managed to use =INDEX(row1,MATCH(9.99999999999999E+307,row1)) which correctly returns the last value (i.e. 7 for row1 in this case) but how could i get the 2nd last, 3rd last, 4th last etc?
With a in A1, in M1 copied across and down to suit:
=MID(RIGHT($B1&$C1&$D1&$E1&$F1&$G1&$H1&$I1&$J1,4),COLUMN()-12,1)
then hide ColumnsB:L.
(Only works for single digits, as shown. Recent versions of Excel may offer better options.)
So I managed to figure out how to do this generically for any digits:
Say your original numerical data is in cells D5:N9.
OPTIONAL:
If any of the rows of data contain the same value twice create a copy in cells D13:N17 which amends duplicates slightly by using in D13 and dragging to fill
=IF(D5="","",D5+0.0001*(COUNTIF($D5:D5,D5)-1))
Then in cells A13:A17 enter values 13,14,15,16,17
and in cells A20:A29 enter values D, E, F, G, H, I, J, K, L, M
In Cell D20 you can return the last from row 13 value using:
=LOOKUP(9.99999999E+307,D13:N13)
and copy this down for each row.
In Cell E20 you can return the 2nd last entry using
=LOOKUP(9.99999999E+307,$D13:INDIRECT(CONCATENATE(INDEX($A$20:$A$29,MATCH(D20,$D13:$N13,0)-1),$A13)))
and copy this down for each row and drag it across to H24 to fill in all the values for 3rd last, 4th last and 5th last for each row.
I have a C column with several rows containing numbers. I have another E Column with rankings.
I would like a formula that will automatically change the number in a 3rd column G based on the ranking in E column
So,
If the ranking is 2 in E the number in G is number in column C
minus 1
If the ranking is 1 the number in E the number in G is
number in column C minus 2
Any other ranking the number remains the
same.
Example -
C E G
19 2 18
12 1 10
15 3 15
Put below formula in G column -
=IF(E1=1,C1-2,IF(E1=2,C1-1,C1))
Above formula is for row 1. Adjust row value according to your need.
Explanation -
Check if E column contains 1, then subtract 2 from C column
Else, check if E column contains 2, then subtract 1 from C
column
Else, G column is same as C column
I have 4 columns in Excel: A, B, C, and D. I want two of the columns (C & D) to auto-populate based on the input in the other two columns (A & B). The first column that auto-populates (C) should start at 1 and increment each time a new value is added in the same row of column B. Column D should also start at 1 and increment each time a new value is added in the same row of column B, however, if column A has the same value as the previous row (i.e., a date) then it should not increment but instead be the same value as column D in the previous row. Additionally, if a value in column B is repeated, but with a different value (i.e., a date) in column A, then it's corresponding value in column C should be the same as before, but the value in column D should still increment because the value in column A is new.
To visualize:
A B C D
Jan. 5 red 1 1
Jan. 5 gre 2 1
Jan. 6 pin 3 2
Jan. 6 pur 4 2
Jan. 7 bla 5 3
Jan. 7 blu 6 3
Jan. 8 red 1 4
Jan. 8 gre 2 4
Jan. 9 yel 7 5
Jan. 9 ora 8 5
I hope this makes sense. Any help would be greatly appreciated!
Assuming "A" is in cell A1, hardcode 1 in C2 and D2 then in C3 and downwards:
=iferror(index($C$2:$C2,match(B3,$B$2:$B2,0)),max($C$2:$C2)+1)
and in D3 and downwards:
=if(A3="","",if(A3=A2,D2,max($D$2:D2)+1))