I have four separate columns:
A
B
C
D
123
123
value1
456
456
value2
789
I want to assign column D values to column B if column A and C match. For example, B:1 should be assigned 'value1', B:2 will be 'value2' and B:3 will be blank.
Try this in cell B1:
=if(A1=C1,D1,"")
For future reference consider looking a little harder for a solution before posting. The formula bears a pretty close resemblance to your actual question... "if... a = c then..."
Found my answer: =IFERROR(VLOOKUP(A1, $C$1:$D, 2, false))
try:
=INDEX(IF((A1:A=C1:C)*(C1:C<>""), "value"&COUNTIFS(
COUNTIFS(A1:A, C1:C, ROW(A1:A), "<="&ROW(C1:C)),
COUNTIFS(A1:A, C1:C, ROW(A1:A), "<="&ROW(C1:C)),
ROW(A1:A), "<="&ROW(C1:C)), ))
Related
I would like to create a google sheet formula that will lookup the ID and return the right-most non-blank score from columns 'Score A', 'Score B' and Score 'D'. Any help would be much appreciated!
ID
Score A
Score B
Score C
Type
2342
65
43
A
8797
B
2343
23
45
98
F
6666
23
B
2333
67
43
B
Assuming E1 is your search_key here's what you can try:
=LET(ζ,TOROW(XLOOKUP(E1,A2:A,B2:D),1),INDEX(ζ,,COUNTA(ζ)))
You may try:
=ifna(lookup(9^9,xlookup(F1,A:A,B:D)))
You can use the following formula. It concatenates for each row the 3 columns into one string and extracts via regex all characters after the last space.
=VLOOKUP(2342,
{
A:A,
ARRAYFORMULA(IFERROR(REGEXEXTRACT(TRIM(B:B&" "&C:C&" "&D:D),"\b(\w+)$")))
},
2)
Just for adding one more option. It won't matter if they're numbers or not, neither if you have empty cells; it will find the non empty cell most to the right
=LET(r,INDEX(2:1000,XMATCH(E1,A2:A)), INDEX (r,,MAX(COLUMN(r)*(r<>""))))
I have the following table:
A
B
Luka, Jean
1
Luka
2
Jean
3
Luka, Jean, Etienne
4
Luka, Jean
5
I would like to have the sum total of every lane containing the name "Luka" and the name "Jean". I am able to have this result but for each unique key containing these names.
My query is : =QUERY(A1:B,"select A, sum(B) where A contains 'Luka' and A contains 'Jean' group by A")
The result is:
sum
Luka, Jean
1
Luka, Jean, Etienne
4
However I would like to have the total result for this query in one unique cell. I think I need to have nested queries but I don't know how to do it.
Expected result :
5 (in one cell without any header or key)
You can try =INDEX(QUERY(QUERY(A1:B,"select A, sum(B) where A contains 'Luka' and A contains 'Jean' group by A"), "select sum(Col2)", 1), 2)
or an actually easier way using your formula itself =INDEX(QUERY(A1:B,"select sum(B) where A contains 'Luka' and A contains 'Jean'"), 2)
First, it seems to me that the total given the sample data in your post should be 10, not 5 (it seems you were not including row 5 for some reason).
Assuming I am correct:
=SUM(FILTER(B:B,ISNUMBER(SEARCH("Luka",A:A)*SEARCH("Jean",A:A))))
I have a google sheet document. In there I have a column of text. I want to fill another column with substrings from each value from the first column, like this:
A | B
a.123 | 123
b.456 | 456
c.789 | 789
If a value is added to column A I want it to automatically appear in column B.
I tried (to no avail):
=ARRAYFORMULA(MID(A2:A, 3, 3))
=MID(ARRAYFORMULA({A2:A}), 3, 3)
=MID({A2:A}, 3, 3)
Which formula in the B2 cell will solve this? Or is it impossible to do from a single cell?
try like this:
=ARRAYFORMULA(MID(A1:A; 3; 3))
and this shall work too:
=ARRAYFORMULA(IFERROR(REGEXEXTRACT(A1:A; ".(\d+)")))
or even:
=ARRAYFORMULA(RIGHT(A1:A; 3))
Link here to spreadsheet
As the title says, how can I end up with cells that don't match in value, the difference/complement (set theory)?
I would prefer it with only FUNCTIONS and no script.
{1,2,3,4}\{1,3} = {2, 4}
or with letters
{a,b,c,d}\{a,c} = {b, d}
or with with space.
{xyz zyx, abc cba, qwe ewq}\{xyz zyx, qwe ewq} = {abc cba}
You can add one single formula at the top of your result column like this :
=arrayformula(if(B2:B=A2:A,,A2:A))
Having two arrays:
Array1 Array2
1 1
2 b
b
4
c
you can get resulting array:
Result
2
4
c
Try this formula:
=FILTER(A2:A6,ROUND(MMULT(ArrayFormula(--(A2:A6<>TRANSPOSE(B2:B4))),TRANSPOSE(SPLIT(REPT(1/ROWS(B2:B4)&"/",Rows(B2:B4)),"/"))),5)=1)
May be too complex for this task, could somebody edit it? Please, look at sample sheet
Edit
I've found more simple way to do this, using Regular Expressions:
=FILTER(A2:A6,REGEXMATCH(ARRAYFORMULA("'"&A2:A6),JOIN("|",B2:B3))=false)
Given a spreadsheet with two columns, say A and B, each containing n values under it, all text; is there a formula that allows me to fill just one cell containing the amount of equal values in columns A and B?
Example:
A B
-----
1 M M
2 L M
3 L L
4 M M
5 M L
-----
3
Since columns A and B both contain an M in rows 1 and 4, and an L in row 3, the result is (i.e. 2+1).
A simple solution is to use QUERY function in google spreadsheet:
=SUM(QUERY(A1:B5, "Select 1 where A = B"))
Or using SUMPRODUCT:
=ARRAYFORMULA(SUM(((A:A)=(B:B)) * (1) ))
One of possible solution will be to add the following formula in column C: =N(EXACT(A1,B1)),
copy it throughout the column down to the last row and then sum up the column C values using =SUM(C1:C5).
Here we go:
=IF(EQ(LEFT(A0, 1), "A"),
SUM(ARRAYFORMULA(N(EXACT(TRANSPOSE(A1:A5), TRANSPOSE(B1:B5))))),
"")
Reading: if the value in row 0 (it doesn't exist, but my example above does ;) ) is equal to the text "A", take the sum of an array N, otherwise put in an empty string. ("")
Array N is build by taking the transpose of columns A and B. (Turning them, so they look like a row) and comparing the values. (Burnash gave me the options "N" and "EXACT") The formula N transforms this into a 1 or 0.
Copy paste the formula in an entire row and what do you know... It worked! That was hellish for something so trivial.
Thanks anyway.