Google Sheets: lookup a value in a table then find right most non-blank value in specified columns - google-sheets

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
Latency
2342
C
C+
44
8797
67
2343
A
B
D
65
6666
A+
22
2333
D
D+
98

This should work for both text-grades and numerical scores
=lambda(Σ,ifna(index(Σ,match(2,1/(Σ<>"")))))(xlookup(G1,A:A,B:D,))

Related

How do I sum the cells of one column based on unique duplicate rows of other columns?

I need column D summed wherever column A-C are identical. Column E is what I want the output to look like. I am only using google sheet functions right now and have not learned how to write script. This formula is the closest I've gotten.
=SUM(filter(D:D;COUNTIF(A2:A&B:B&C:C;A2:A&B:B&C:C)>1))
However, it does not distinguish between different text strings only sums any duplicate.
Thanks for any help!
A
B
C
D
E
papaya
10/10/2022
500
42
42
papaya
15/12/2022
550
30
59
papaya
15/12/2022
550
29
59
Pineapple
16/11/2022
400
55
55
Pineapple
09/11/2022
400
63
78
Pineapple
09/11/2022
400
15
78
use:
=QUERY(A:E; "select A,B,C,sum(D) where D is not null group by A,B,C label sum(D)''")
update
use in M2:
=INDEX(LAMBDA(bc; g; i; IFERROR(g/VLOOKUP(bc; QUERY({bc\i*1};
"select Col1,sum(Col2) where Col2 > 0 group by Col1 label sum(Col2)''"); 2; )))
(B2:B&C2:C; G2:G; I2:I))

Copy over data with concatenating few columns together

In my google sheets I have two sheets/tabs.
In Sheet 1 I have below columns
A
B
C
D
1
Phone#
St Address
City
Buzzer#
2
123
Street 1
Toronto
564
3
456
Street 2
Cambridge
4
523
Street 1
Guelph
5
412
Street 1
Barrie
985
In my sheet 2 I want to copy all these data as below format. I am trying to copy over column A -> Phone# Column as is and concatenate column B | Column C | Column D columns together with ,. Where if There is Buzzer number I want to append word Buzzer end of the city name otherwise leave it blank.
A
B
1
Phone#
Complete Address
2
123
Street 1, Toronto, Buzzer 564
3
456
Street 2, Cambridge
4
523
Street 1, Guelph
5
412
Street 1, Barrie, Buzzer 985
And Here is How I have tried to copy over data from Sheet1 to sheet2 and concatenate columns B,C,D together
=Query('Sheet1'!A:D,"Select A and CONCATENATE((IF(D<>"",(CONCATENATE("Buzzer-"," ",D,", ")),"")),B,", ",C,", ",D) where A is not null",1)
Obviously this didn't work.
Any suggestions or Help please?
I've made a quick sheet with the solution using:
=ARRAYFORMULA(IF(ISBLANK(Sheet1!A2:A12), "",ARRAYFORMULA({Sheet1!A2:A12,ARRAYFORMULA(Sheet1!B2:B12&", "&Sheet1!C2:C12&", "&Sheet1!D2:D12)})))
The sheet:
https://docs.google.com/spreadsheets/d/1E1lBW63CyVJAUmq1okIQgn6-FY82QHt829hpeb0yWxw/edit?usp=sharing

Concatenating from table to string, sum amounts

Consider the Google Sheets table below:
A B C D
1 category subcategory company amount
2 health care diagnostics AA 100
3 health care diagnostics AB 50
4 materials mining BA 75
5 financials banks CA 30
6 financials insurers CB 35
7 financials banks CC 10
8 financials banks CD 40
9 financials hedge fund CE 5
10 health care equipment DA 50
I would like to list, per subcategory, the companies in it, and the amount spent:
A B C
1 category companies amount
2 health care AA AB DA 200 <--- 100 + 50 + 50
3 materials BA 75
4 financials CA CB CC CD CE 120
Column A I will type myself / hardcode. But what formula in column B and C will give this result, depending on the value in A?
try:
=ARRAYFORMULA(IFNA(VLOOKUP(E3:E, QUERY({QUERY({A:D},
"select Col1,sum(Col4)
where Col1 is not null
group by Col1
label sum(Col4)'amount'", 1), {"companies";
TRIM(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY({A:D, C:C},
"select max(Col3)
where Col1 is not null
group by Col1
pivot Col5"),
"offset 1", 0)),,9^9)))}},
"select Col1,Col3,Col2", 1), {2,3}, 0)))
where E3:E are your hardcoded values

Concatenating from a table by filtering first

Consider the table below:
A B C D
1 category subcategory company amount
2 health care diagnostics AA 100
3 health care diagnostics AB 50
4 materials mining BA 75
5 financials banks CA 30
6 financials insurers CB 35
7 financials banks CC 10
8 financials banks CD 40
9 financials hedge fund CE 5
10 health care equipment DA 50
I want to (1) concatenate the companies for each category and (2) return the aggregated amount.
A B C
1 category companies amount
2 health care AA AB DA 200 <--- 100 + 50 + 50
3 materials BA 75
4 financials CA CB CC CD CE 120
I am aware that (2) can easily be done by using a pivot table, but (1) is not supported by pivots. So given the excel below, what formula do I need in B1 and C1 to get the desired output?
A B C
1 category
2 health care
3 materials
4 financials
I have looked into concatenate(), which is needed here, but I don't see how I can give arguments to that function, like pseudo:
=concatenate(C2:C10; "where (A:A) = 'health care')
Who can help me out?
=ARRAYFORMULA(QUERY({QUERY({A:D},
"select Col1,sum(Col4)
where Col1 is not null
group by Col1
label sum(Col4)'amount'", 1), {"companies";
TRIM(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY({A:D, C:C},
"select max(Col3)
where Col1 is not null
group by Col1
pivot Col5"),
"offset 1", 0)),,9^9)))}},
"select Col1,Col3,Col2", 1))

Google Sheets filter formula get specific columns, plus between two dates

I am building somewhat of an invoice report tool where I would like to pull all of Client X's orders between the dates set in A1 and A2, but I only need 6 of the 35 columns.
So far I am able to use the =filter formula with ease but I get all the columns of course, and I have no idea how to only filter based on the dates in A1 and A2.
If my sample data is below, I want to be able to pull all records for Client 1, between the dates set in A1 and A2 and only show Col1, Col3, and Col 6 in my "report"
Row Col1 Col2 Col3 Col4 Col5 Col6
1 Client 1 $45.00 01/15/2016 123 Main Street 404-989-9999 John
2 Client 1 $75.00 01/17/2016 123 Main Street 404-989-9999 John
3 Client 3 $15.00 01/18/2016 456 Park Street 404-989-9999 Sue
4 Client 4 $35.00 01/18/2016 111 East Street 404-989-9999 Chris
5 Client 5 $95.00 01/19/2016 789 North Street 404-989-9999 Tim
6 Client 3 $65.00 01/20/2016 456 Park Street 404-989-9999 Sue
7 Client 3 $25.00 01/21/2016 456 Park Street 404-989-9999 Sue
8 Client 1 $45.00 01/22/2016 123 Main Street 404-989-9999 John
One way to achieve that would be the use of query()
=query(A2:F, "select A, C, F where A='Client 1' and C >= date'"&text(A1, "yyyy-mm-dd")&"' and C <= date '"&text(B1, "yyyy-mm-dd")&"' " ,0)
Change ranges to suit.
Another way (with filter) would look something like this:
=filter({A2:A, C2:C, F2:F}, A2:A="Client 1", C2:C >= A1, C2:C <= B1)
I hope that helps ?

Resources