How to array unique in google spreadsheet? - google-sheets

I have data like this:
Cage Type
Open House, Open House
How to make it like this? so I can get a unique list.
Cage Type
Unique Cage
Open House, Open House
Open House

Use this
=TEXTJOIN(", ",1,UNIQUE(TRANSPOSE(SPLIT(A2, ", ",0))))
Arrayformula
=BYROW(A2:A, LAMBDA(r, IFERROR(TEXTJOIN(", ",1,UNIQUE(TRANSPOSE(SPLIT(r, ", ",0)))),"")))

try:
=INDEX(FLATTEN(REGEXREPLACE(TRIM(QUERY(QUERY(QUERY(SPLIT(UNIQUE(FLATTEN(
FILTER(ROW(A:A)&"​"&SPLIT(A:A, ", ", )&",", A:A<>""))), "​"),
"select max(Col2) where Col2<>',' group by Col2 pivot Col1"),
"offset 1", ),,9^9)), ",$", )))

Related

Formatting 3 column array in Google Sheets with unique counts

I have the following data and the work-in-progress formula
=ARRAYFORMULA({unique(A2:A);flatten(UNIQUE(filter(C2:C, A2:A=A2))&": "&countif(filter(C2:C, A2:A=A2),UNIQUE(filter(C2:C, A2:A=A2))))})
How can I go about creating the DESIRED OUTPUT from the dataset?
Google Sheet link: https://docs.google.com/spreadsheets/d/1F-ZRe0hgFWdb318xHtiIGmR-RvxSgv518k9wCUBfCm0/edit?usp=sharing
The query() function lets you get those results, although they will be tabulated in a format that is different from what you requested:
=query(A1:C, "select A, count(A) where C is not null group by A pivot C", 1)
use:
=INDEX(LAMBDA(x, y,
QUERY(FLATTEN({SORT(UNIQUE(FILTER({IFERROR(x/0, "​"), x}, x<>""))),
IF(QUERY(y, "offset 1", )="",,INDEX(y, 1)&": "&QUERY(y, "offset 1", ))}),
"where Col1 is not null offset 1", ))
(A2:A, QUERY(A2:C, "select count(A) where C is not null group by A pivot C")))

Join range of row using arrayformula

I have a range of data on column A and B. In Column D , i have a reference for the shotID. I want to make a list for the artist involved for specific shotID.
In E2 i use this :
=JOIN( "," , FILTER($B$2:$B, $A$2:$A= D2))
then copy down to E3,E4. It works as i expected, but i want to do it using array formula. So only use single formula in E2 and that doesn't work that simple :
=arrayformula( JOIN( "," , FILTER($B$2:$B, $A$2:$A= D2:D4)) )
How can i do this ?
One more possibility that I learned from player0 and surprised he didn't suggest...
=ARRAYFORMULA(SPLIT(TRANSPOSE(SUBSTITUTE(TRIM(QUERY(QUERY(A2:B&{"|",CHAR(10)},"select MAX(Col2) where Col1<>'|' group by Col2 pivot Col1"),,100)),CHAR(10),",")),"| ",0))
take:
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(SUBSTITUTE(
FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY(SPLIT(
FLATTEN(A2:A&"×"&B2:B&","&"×"&B2:B), "×"),
"select Col1,max(Col2) where Col2 is not null group by Col1 pivot Col3"),
"offset 1", 0)),,9^9)), " ", "×", 1), "×")), ",$", ))
You could also try:
={unique(A2:A),arrayformula(transpose(substitute(trim(query(if(A2:A<>transpose(unique(A2:A)),,B2:B),,9^9))," ",", ")))}

Combining rows based on IDs on 2 columns Formula in Google Sheets

I have data that looks like this:
And I want it to look like this:
Formula ideas?
Thanks!
Maria
try:
=ARRAYFORMULA(TRIM(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY({A2:A&"×"&B2:B,
TRIM(FLATTEN(QUERY(TRANSPOSE({"×"&C2:D}),,9^9))),
TRIM(FLATTEN(QUERY(TRANSPOSE(C2:D),,9^9)))},
"select Col1, max(Col2) where Col3 is not null group by Col1 pivot Col3"),
"offset 1", 0)),, 9^9)), "×")))

How can I get a QUERY to CONCATENATE text after it combines data?

On this sheet, I've been working on I have the info I need adjusting down into the Query Results
=QUERY(Investors!A4:D,
"select B,C,sum(D)
where B is not null
group by B,C
label sum(D)''")
How do I get the Stock Numbers Due that day to be listed out in column D? Like this:
1. 10/7/2019 Grady Johnson $100.12 PT-1013
2. 11/15/2020 Bill Jones $553.80 PT-1020, PT-1019
3. 11/15/2020 Grady Johnson $45.00 PT-1011
4. 11/15/2020 Steve Robinson $320.00 PT-1018, PT-1016
5. 11/17/2020 Jim Luke $1,057.20 PT-1009, PT-1008, PT-1007, PT-1006
6. 11/22/2020 Jim Luke $300.43 PT-1010
Here's the link: Google Sheet
Any help is appreciated!
or paste this in row 3 and drag down:
=JOIN(", ", IFNA(FILTER(Investors!A$4:A, Investors!B$4:B&" "&Investors!C$4:C=A3&" "&B3)))
try:
=ARRAYFORMULA(REGEXREPLACE(IFNA(VLOOKUP(TO_TEXT(A3:A)&" "&B3:B,
TRIM({TRANSPOSE(QUERY(TRANSPOSE(QUERY(QUERY({Investors!A4:C},
"select Col2,Col3,count(Col2) where Col2 is not null group by Col2,Col3 pivot Col1"),
"select Col1,Col2 offset 1", 0)),,9^9)),
TRANSPOSE(QUERY(TRANSPOSE(IF(QUERY(QUERY({Investors!A4:C},
"select count(Col2) where Col2 is not null group by Col2,Col3 pivot Col1"),
"offset 1", 0)="",,
QUERY(QUERY({Investors!A4:A&",", Investors!B4:C},
"select count(Col2) where Col2 is not null group by Col2,Col3 pivot Col1"),
"limit 0", 1))),,9^9))}), 2, 0)), ",$", ))
Here is my suggested formula to be placed in Combined!D3 of your sample spreadsheet:
=ArrayFormula(IF(A3:A="",,SUBSTITUTE(TRIM(TRANSPOSE(QUERY(TRANSPOSE(IF(VLOOKUP(TRANSPOSE(FILTER(Investors!A4:A,Investors!A4:A<>"")),{Investors!A:A,Investors!C:C&Investors!B:B},2,FALSE)=B3:B&A3:A,TRANSPOSE(FILTER(Investors!A4:A,Investors!A4:A<>"")),))," ",COUNTA(Investors!A4:A))))," ",", ")))
As for how it works, that would be time-consuming to explain. (More time than is reasonable for a free site such as this.) I will suggest that, if this is important to you, take the time to study it. Take it apart and see what each piece does — separately and then in combination with other parts — until you've gotten it all back together.

Summarizing array of existing items and amounts from a range

I want to speed up work in my catering company. I have an excel file with all the ingredients of all products.
For example:
https://docs.google.com/spreadsheets/d/1-AFHpl8aoIiMXz2RE1Xv7JcI7pCIMQfMoq-lQJBx5Gw/edit?usp=sharing
=ARRAYFORMULA(TRIM(SPLIT(TRANSPOSE(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(master!E3:Z<>"", master!A3:A&"♦"&master!B3:B&"♦"&master!E1:1&"♦"&master!E3:Z&"♠", ))
, , 500000)), , 500000)), "♠")), "♦")))
=ARRAYFORMULA(QUERY({C2:C,VALUE(D2:D)},
"select Col1,sum(Col2)
where Col1<>''
group by Col1
order by Col1
label sum(Col2)'Total',Col1'Shopping List'"))
The following formula would work for one recipe:
=TRANSPOSE(FILTER({E1:K1;QUERY(A1:K5,"SELECT E,F,G,H,I,J,K WHERE A='"&H25&"'", FALSE)}, NOT(ISBLANK(QUERY(A1:K5,"SELECT E,F,G,H,I,J,K WHERE A='"&H25&"'", FALSE)))))
(I put this as an example into cell I25).

Resources