Any thoughts why doesn't this work? I need the J column to be auto-populated.
It works correctly if I just stretch down the formula.
However I need it to dynamically adjust its size according to the number of elements in column G
Is that even achievable?
try:
=QUERY(H6:H, "offset 1", 0)
or in array:
=ARRAYFORMULA({G6:G, QUERY(H6:H, "offset 1", 0)})
UPDATE:
F3 cell:
=FILTER(B2:B; MOD(ROW(A2:A)-2; 4)=0)
G3 cell:
=FILTER(B2:B; MOD(ROW(A2:A)-3; 4)=0)
H3 cell:
=FILTER(B2:B; MOD(ROW(A2:A)-1; 4)=0)
I3 cell:
=FILTER(C2:C; MOD(ROW(A2:A); 4)=0)
I think that I may have something that helps you. The only weakness is that it currently uses two "helper" columns. With some on the formula, these could be removed. Here is my sample.
First, I generate more of a database structure for the data, adding the element name to each row of data, where you have blanks in column A. I also pull the "prop4" value from the second column. If your data structure for column B and C is different then what you've shown, this formula might need adjustment.
This formula does that:
FILTER(ARRAYFORMULA({
VLOOKUP(ROW(A2:A);
IF(A2:A<>"";
{ROW(A2:A)\ A2:A});
2; 1)
\
IF(LEN(B2:B);
IF(MOD(ROW(B2:B);4)=0;
C2:C;B2:B);
ISERROR(1/0))
});
LEN(B2:B))
The result looks like column K and L in this:
Then I use a query based formula on this intermediate result, giving the final result table. The formula here (found in this question) is:
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(TRANSPOSE(QUERY(QUERY(
IF(L1:L<>""; {K1:K&"♠"\ L1:L&"~"}; );
"select max(Col2) where Col1 is not null group by Col2 pivot Col1")
;;999^99)); "♠~";1;1)); "~$"; ))
I tested this by adding an element "block" at the end of column A, and by deleting an element block in the middle of column A, both of which which worked fine.
Let us know if that is the result you want. If not, please explain exactly what you expect, given your data.
Related
I’m trying to find every instance of a name in a list of names, and compile their locations in a list. I already know TEXTJOIN can do this with comma delineation, but I can’t figure out how to implement it.
I’ve tried using FIND, SEARCH, and MATCH in various ways, but can’t get it to work.
Here’s a mockup, where the filled in section is the goal.
This is the formula I’m trying to use:
=INDEX(IFNA(VLOOKUP(E2:E, QUERY(L:O, "select L,sum(O) where L is not null group by L label sum(O)''"), 2))
Update:
And here’s an actual graph photo.
For reference, Base Stakes and Results work perfectly, the only issue being that they are referring to the ELO column(the one for which the desired result is filled in), which is broken. How should I translate the working formula to function without detecting circular logic?
try:
=QUERY(D:F; "select D,sum(F) where D is not null group by D label sum(F)''")
if you insist on injection use:
=INDEX(IFNA(VLOOKUP(A2:A; QUERY(D:F;
"select D,sum(F) where D is not null group by D label sum(F)''"); 2; )))
update:
use in F2:
=INDEX(IFNA(VLOOKUP(E2:E, QUERY({L:L, O:O},
"select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col2)''"), 2, )))
Formula in Table 1 $A$2
=MAP(SORT(UNIQUE(D2:D)),
LAMBDA(n, IF(n<>"",
{n,SUM(INDEX(FILTER(D:F,D:D=n),,3))},"")))
I have a Sheet with a database of names, the group they are in, and the color they have earned (that's the short explanation). It looks like this:
I want to create a tab where the colors for each group are placed in one cell with a comma in between, like this:
I can get this output by using this formula [in B2 on the output sheet]:
=IF(A2:A<>"",JOIN(", ",FILTER(Sheet1!C2:C,Sheet1!B2:B =A2)),"")
I would like to take this formula above and turn it into an Array so that it will automatically apply down the whole column as groups are added or taken off the input database. I tried using this formula in B1, but the condition in the filter function, meant to apply to each row, is just outputting everything.
={"Colors"; ARRAYFORMULA(IF(A2:A<>"",JOIN(", ",FILTER(Sheet1!C2:C,Sheet1!B2:B =A2:A)),""))}
Suggestions to make the Array Formula output like shown in the second picture?
TIA
EDIT: In the actual database, there is several columns of data for each person (not just color) and I want to be able to return the array format for each. So, on the output tab there might be an array of colors for each group in Col B, but then an array of ages in C, heights in D, etc.
Here is a link to my example
use:
=ARRAYFORMULA(REGEXREPLACE(TRIM(SPLIT(FLATTEN(QUERY(QUERY({B1:B&"×", C1:C&",", ROW(B1:B)},
"select max(Col2) where Col1 <> '×' group by Col3 pivot Col1"),,9^9)), "×")), ",$", ))
I'm pretty new with ArrayFormula, have been trying but sometime the formula works, sometimes does not. What I'm trying to do is the combination of ArrayFormula, Countif for searching partial text.
As shown in the worksheet below, there are 10 subjects (column A), each subject has at least one of 4 samples (A,B,C,D) summarized as a string (column B). What I'm trying to do is to find which subject has sample A or B or C or D.
I have tried single formula for each sample, eg cell D3
=IF(COUNTIF($B3,"*"&$D$2&"*")>0,$A3,"")
it returns the correct results. However, when I try arrayformula in cell I3,
=arrayformula(IF(COUNTIF($B3:B,"*"&$D$2&"*")>0,$A3:A,""))
The answers are weird. For example: Subjects (Gamma, Zeta, Eta, Theta) who don't have the sample "A" are shown to have sample "A". And this applies to sample B,C,D too
Not sure what went wrong in here. Here is the link to the worksheet
I wouldn't use Countifs or an array formula. Use filter instead. Put this formula in cell i3.
=Filter(if(REGEXMATCH(B3:B,$D$2),A3:A,""),B3:B<>"")
try:
=INDEX(QUERY(IFERROR(TRIM(SPLIT(FLATTEN(IF(IFERROR(SPLIT(B3:B, ","))="",,
SPLIT(B3:B, ",")&"×"&A3:A)), "×"))),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"))
or use in row 2 if you want to sort it as in your example:
=INDEX(IFNA(VLOOKUP(A2:A, QUERY(IFERROR(TRIM(SPLIT(FLATTEN(
IF(IFERROR(SPLIT(B3:B, ","))="",,SPLIT(B3:B, ",")&"×"&A3:A)), "×"))),
"select Col2,max(Col2) where Col2 is not null group by Col2
pivot Col1 label Col2'Subjects'"), {2,3,4,5}, 0)))
You can accomplish all four columns of results with a single formula.
Delete all formulas from I3:L3.
Place the following formula into I3:
=ArrayFormula(IF(REGEXMATCH(B3:B,I2:L2),A3:A,))
In plain speech, this read "If anything in B3:B matches a value found in I2:L2, return A3:A in the matching columns(s) at the matching row(s); if not, return null."
Below is my query function in its original form:
=ArrayFormula(query({importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","CPG!A2:L20");importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","PUB!A2:L20")},"Select Col5, Sum (Col4) where Col6='' group by Col5 pivot Col7"))
Which I am trying to shorten the formula by using indirect to refer to concatenated import ranges by the following attempt
=ArrayFormula(query(indirect("JOIN!J3"),"Select Col5, Sum (Col4) where Col6='' group by Col5 pivot Col7"))
but come up with this error:
Error
Unable to parse query string for
Function QUERY parameter 2:
NO COLUMN: Col5
The Join!J3 cell contains the value below:
{importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","CPG!A2:L20");importrange("1yqTUmJcL6YxgOpfHS5Pt9nYnmpiqN3tUPQP7-Rp8xis","PUB!A2:L20")}
I research various similar question in forums but their answers comes to no solution. Usually it is to use "Select Col1" instead of "Select A" but my formulas are all using Col1, Col2 already. Am doing anything wrong?
I have included some images for further clarification.
The original formula:
The shortening attempt:
The cell value in sheetname: JOIN cell: J3:
The cell value in J3 is actually a pasted value from cell A1:
If I understand correctly, because your formula is now referring to a specific range in the sheet instead of an array of ranges, you will need to use A, B instead of Col1, Col2, etc.
I assume the data produced by cell J3 in the sheet JOIN displays data in J3:U21 (based on the range A2:J20). You need to query all of this, not just the cell containing the formula.
Try the formula below.
(I have made assumptions about what columns the data sits in--please amend where necessary).
=ArrayFormula(query(indirect("JOIN!J3:U21"),"Select N, Sum (M) where O='' group by N pivot P")
EDIT: You seem to be using the same range and ID. You can refer to them using just two cells.
={IMPORTRANGE(D6,"SheetName1"&E6);IMPORTRANGE(D6,"SheetName2"&E6)}
I am trying to get the some of all values in row B that contain a certain value in row A. Pretty simple problem I guess.
Here is my query:
=QUERY('Sheet1'!$A$16:D, "Select sum(D) Where C contains '"&C5&"' ", -1)
But what that gives me is the actual word "sum" in all the fields where C contains the value.
So I get a lot of "sum" in almost all my rows.
Did the "sum" statement change for queries in google spreadsheets?
It looks like you are using more than one query formula: apparently there is a column with query, each referring to a cell such as C5. In this case there is no room for column label "sum" that the formula wants to insert: the output must be a single cell. Solution: change the column label to empty string with label sum(D) ''.
=QUERY('Sheet1'!$A$16:D, "Select sum(D) Where C contains '"&C5&"' label sum(D) ''", -1)