I want to get the matrices with reference in the cells - google-sheets

The formula works when I type manually, but when I try to get the references of the tabs inside the cells it doesn't work, can someone help me?
https://docs.google.com/spreadsheets/d/1KVyLhBRamHyjq_DD92X78OfBvzh0bUDTnf_WTojTnpg/edit#gid=2097694625
I tried to put it like this, but it didn't work.

try:
=QUERY({REDUCE({"","","","","","","","",""},
FILTER(L5:L, L5:L<>""), LAMBDA(a, b,
{a; IFERROR(INDIRECT(b&"!G1:O"), {"","","","","","","","",""})}))},
"where not Col8 is null", )
where L5:L is your:
see: https://stackoverflow.com/a/74483215/5632629
UPDATE:
=QUERY({REDUCE({""\""\""\""\""\""\""\""\""};
FILTER(SHEETSNAME(); REGEXMATCH(SHEETSNAME(); "sin")); LAMBDA(a; b;
{a; IFERROR(INDIRECT(b&"!G1:O"); {""\""\""\""\""\""\""\""\""})}))};
"where not Col8 is null"; )

Related

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

Google sheet arrayformula doesn't work with (Index(query(filter)

I would like to use the following formula in arrayformula so I do not need to pull down if new entries appear. Can you help please what am i missing? Thank you.
=Arrayformula(INDEX(Query(FILTER(B2:B, C2:C=I2:I), "select Col1 where Col1 is not null", false), 1, 1))
try:
=FILTER(B2:B, C2:C=I2:I, C2:C<>"")

Finding the top 3 values and returning the column ID

Thank you beforehand for your kind response.
Problem: I am trying to do a sheet to sort out the 3 top categories of a given range as shown by the attached screen grab.
enter image description here
I only managed to get the results by using the "large" command. "=large(range,n)". Using this I got the value but what I need is the column index/id rather than the numeric values.
Any ideas on how I would go about achieving this?
Thanks for your reply.
Try the following maybe:
Formula in G2:
=TRANSPOSE(QUERY(TRANSPOSE({A$1:E$1;A2:E2}),"Select Col1 Order by Col2 desc limit 3"))
It's definitely possible in arrayformula.
Using vlookup, a sequence of numbers for the search key:
=arrayformula(sequence(max(if(A:E<>"",row(A:A),))-1,columns(A:E)))
...and a range of columns that are sorted by each row of numbers:
=arrayformula({
sequence((max(if(A:E<>"",row(A:A),))-1)*columns(A1:E1)),
sort({
array_constrain(int((row(A2:A)-2)/(columns(A:E)))+1,(max(if(A:E<>"",row(A:A),))-1)*columns(A1:E1),1),
array_constrain(iferror(split(flatten(if(A2:E<>"",A1:E1&char(9999),)&A2:E),char(9999)),),(max(if(A:E<>"",row(A:A),))-1)*columns(A1:E1),2)
},1,1,3,0)
})
The final formula for the solution, in cell G2:
=arrayformula(
array_constrain(
vlookup(
sequence(max(if(A:E<>"",row(A:A),))-1,columns(A:E)),
{sequence((max(if(A:E<>"",row(A:A),))-1)*columns(A1:E1)),sort({array_constrain(int((row(A2:A)-2)/(columns(A:E)))+1,(max(if(A:E<>"",row(A:A),))-1)*columns(A1:E1),1),array_constrain(iferror(split(flatten(if(A2:E<>"",A1:E1&char(9999),)&A2:E),char(9999)),),(max(if(A:E<>"",row(A:A),))-1)*columns(A1:E1),2)},1,1,3,0)}
,3,0),
max(if(A:E<>"",row(A:A),))-1,3)
)
It will work with blank cells in some of the rows.
The width of the source data is determined by:
=columns(A1:E1)
and the height of the source 'numbers' by:
=max(if(A:E<>"",row(A:A),))-1 (it needs to sit within an arrayformula).
you may use this superior formula:
=ARRAYFORMULA(ARRAY_CONSTRAIN(IFERROR(SPLIT(FLATTEN(SPLIT(QUERY(FILTER(
QUERY(SPLIT(FLATTEN(IF(A2:E="",,ROW(A2:A)&"×"&A2:E&"×"&A1:E1)), "×"),
"select Col3 where Col2 is not null order by Col1,Col2 desc"), COUNTIFS(
QUERY(SPLIT(FLATTEN(IF(A2:E="",,ROW(A2:A)&"×"&A2:E&"×"&A1:E1)), "×"),
"select Col1 where Col2 is not null order by Col1,Col2 desc"),
QUERY(SPLIT(FLATTEN(IF(A2:E="",,ROW(A2:A)&"×"&A2:E&"×"&A1:E1)), "×"),
"select Col1 where Col2 is not null order by Col1,Col2 desc"),
SEQUENCE(COUNTA(A2:E), 1, ROW(A2)), "<="&SEQUENCE(COUNTA(A2:E), 1, ROW(A2)))<4)&
FLATTEN(IFERROR(SEQUENCE(MAX((A2:E<>"")*ROW(A2:A)), 3)*
{"a", "a", 0})),,9^9), 0)), " ")), 9^9, 3))

Concatenate cell values if they have a similar value in another cell

I need to concatenate the city names that a person has been to into another cell but they have to be repeated every time the name of the person comes up.
I tried using COUNTIF but couldn't get me anywhere.
I don't wanna use VB code; just formulas/functions.
Any ideas?
Here's the link to my spreadsheet
use:
=ARRAYFORMULA(REGEXREPLACE(IFNA(VLOOKUP(B2:B,
TRIM(SPLIT(TRANSPOSE(TRIM(QUERY(QUERY({A2:A&",", B2:B&"♦"},
"select max(Col1) where Col1 <> ',' group by Col1 pivot Col2")
,,99^99))), "♦")), 2, 0)), ",$", ))

How to use COUNTUNIQUE function within ArrayFormula and get a range result?

I have tried to use a COUNTUNIQUE function within ArrayFormula in cell 'A2' to get a result in the range like a column B that I've set a function cell by cell. But it returns only a single value. This is my formula in cell 'A2':
=ArrayFormula(COUNTUNIQUE(D2:D7,E2:E7,F2:F7,G2:G7,H2:H7))
Any help will be greatly appreciated!
This problem has interested me for a while. Basically, the solution from #player0 seems obvious to me. But it is difficult to read.
Perhaps using combined arrays and implicit endings search is more appropriate:
=INDEX(
COUNTIF(
UNIQUE(FLATTEN(
{"" & ROW(C2:Z), ROW(C2:Z) & "-" & C2:Z}
)),
ROW(C2:Z7) & "-*"
) - 1
)
you can do it like this:
=ARRAYFORMULA(QUERY(UNIQUE(TRIM(SPLIT(TRANSPOSE(SPLIT(QUERY(TRANSPOSE(QUERY(TRANSPOSE(
IF(D2:K<>"", "♦"&ROW(A2:A)&"♥"&D2:K, )),,999^99)),,999^99), "♦")), "♥"))),
"select count(Col1) where Col1 is not null group by Col1 label count(Col1)''", 0))
or like this:
=ARRAYFORMULA({
COUNTUNIQUE(D2:H2);
COUNTUNIQUE(D3:H3);
COUNTUNIQUE(D4:H4);
COUNTUNIQUE(D5:H5);
COUNTUNIQUE(D6:H6);
COUNTUNIQUE(D7:H7)})

Resources