Copy over data with concatenating few columns together - google-sheets

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

Related

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

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,))

Horizontal Lookup using Index Match on Google Sheets

For the following image from Google Sheets, I want to fill out column L with the value found in column A "PPID" based on values in column J "ID" and referencing the range columns B-I. For example, the value "123" should be filled out in column L for the IDs in column J that are 981296581, 682975586, etc. I tried using Index-Match formula, such as =INDEX($A$3, MATCH(J3,B3, 0)), but it only worked for the first row of data and showed an error for the remaining rows
Here is the screenshot of my Google Sheets, as well as the tables below it if you need to copy it into your Google Sheets:
SHEET 1
PPID
ID
ID
ID
ID
ID
ID
ID
ID
123
981296581
682975586
6144233
6140531
6047231
4540543
134
34
456
815220681
1532839
1141531
SHEET 2
ID
INTENDED RESULT
COLUMN TO FILL OUT (with formula)
981296581
123
682975586
123
6144233
123
6140531
123
6047231
123
4540543
123
134
123
34
123
815220681
456
1532839
456
1141531
456
Thanks!
The format isn't really conducive for a lookup. We can FLATTEN the key range and "repeat and flatten" the value range(with IF) to make it conducive for any lookup.
=ARRAYFORMULA(
XLOOKUP(
K2:K12,
FLATTEN(B2:I3),
FLATTEN(IF(COLUMN(B2:I3),A2:A3,))
)
)
ID(K1)
INTENDED RESULT
COLUMN TO FILL OUT (with formula)
981296581
123
123
682975586
123
123
6144233
123
123
6140531
123
123
6047231
123
123
4540543
123
123
134
123
123
34
123
123
815220681
456
456
1532839
456
456
1141531
456
456
try:
=INDEX(IFERROR(VLOOKUP(J3:J, IFERROR(SPLIT(FLATTEN(
IF(B3:I="",,B3:I&"×"&A3:A)), "×")), 2, 0)))
Use this
=ArrayFormula(IF(A3="",,
BYROW(B3:I3, LAMBDA(l, IF(ARRAY_CONSTRAIN(QUERY(
TRANSPOSE(REGEXMATCH(J3&"",l&"")), "Select Col1 where Col1 = TRUE"),1,1)<>TRUE,,A3)))))

How to combine two tables with common headers in google sheets?

I am trying to combine two tables with common headers. The formula below only properly works, if I define the exact start and end row. How can I adjust the formula below to dynamically fetch non blank rows from both the tables.
=iferror({A1:C50;ArrayFormula(hlookup(A1:C1,'Settings'!A1:C50,row(A2:A50),0))})
Sample Input:
Table 1
col 1
col2
col 3
abc
123
789
def
456
1212
Table 2
col 1
col2
col 3
abc
123
78849
jkl
256
1298
Desired Output:
Table 3
col 1
col2
col 3
abc
123
789
def
456
1212
abc
123
78849
jkl
256
1298
Use OUERY:
=QUERY({A1:C1;A2:C;E2:G},"WHERE Col1 IS NOT NULL")

How to sort data into a table from columns with duplicate names with different information for each row

So I have this data:
Name Post ID
CASTILLO, FIONA SN 32
ALDERETE, ROSABEL AN 56
ALDERETE, ROSABEL GN 11
ALMONARES, OLIVER SN 3
ALMONARES, OLIVER GN 2
ALVAREZ, JR., EDUARDO GN 36
ALVAREZ, JR., EDUARDO AN 1
ARELLANO, DONNALYN SN 36
ARELLANO, DONNALYN AN 63
ARELLANO, DONNALYN GN 7
CASTILLO, FIONA SN 1
CASTILLO, FIONA SN 1
DE LEON, AMABEL GN 1
DENNISON, GRETCHEN AN 11
DENNISON, GRETCHEN AN 26
DENNISON, GRETCHEN SN 5
And I want to create a table where the rows are the unique names of the people (not duplicated) and the column headings are Name, SN, AN, GN, and the values inside are the corresponding numbers. I know how to create this using a pivot table But which function would separate the data once the table is created.
The data above are cells A2:C16 and my desired output is C2:C9 would be the names, C1 is the name header, D1 is the SN header, E1 is the AN header, and F1 is the GN header. The values occupying the table would be the ID that corresponds with each person.
try:
=QUERY({A1:C}; "select Col1,max(Col3) where Col1 is not null group by Col1 pivot Col2")
you can change max for min, sum, avg or count if you need so

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