I'm currently obtaining the result with the formula below, which was nicely provided by player0, but the challenge now is to obtain not only the figure found, but a sum, since the occurrences in the "database" may be multiple.
=Arrayformula(if(A9:A="";;IFNA(vlookup(A9:A&D9:D&"Expedição"&"Costura";
{IMPORTRANGE("fileId";"Produção!F2:F")&
IMPORTRANGE("fileId-1n3nQ";"Produção!H2:H")&
IMPORTRANGE("fileId-1n3nQ";"Produção!R2:R")&
IMPORTRANGE("fileId-1n3nQ";"Produção!B2:B")\
IMPORTRANGE("fileId-1n3nQ";"Produção!N2:N")};2;0))))
I have tried including sum in many places in the formula above, but with no success.
Here's a file with dummy data.
Thanks in advance.
use:
=ARRAYFORMULA(IF(A4:A="",,IFNA(VLOOKUP(A4:A&" "&C4:C&" Expedição Costura ",
QUERY(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY({IMPORTRANGE(
"1gh5w0czg2JuoA3i5wPu8_eOpC4Q4TXIRhmUrg53nKMU", "Data Origin!A2:R")},
"select Col6,Col8,Col18,Col2,'×',Col14 where Col14>0 label '×'''", )),,9^9)), "×"),
"select Col1,sum(Col2) where Col2>0 group by Col1"), 2, 0))))
Related
I want to use a formula to find the highest N values in each group in a Google Spread Sheets.
I tried this formula from infoinspired.com (credit to Prashanth):
=ArrayFormula(QUERY({SORT(A2:B;1;true;2;false);IFERROR(row(A2:A)-match(query(SORT(A2:B;1;true;2;false);"Select Col1");query(SORT(A2:B;1;true;2;false);"Select Col1");0))};"Select Col1,Col2 where Col3<3"))
But all it return is an Array_Literal error:
This is what I expect:
What is wrong with it?
You have to put a comma, not a semi colon before IFERROR. It's creating two columns, one twice larger than the other instead of three columns ;)
=ArrayFormula(QUERY({SORT(A2:B,1,true,2,false),IFERROR(row(A2:A)-match(query(SORT(A2:B,1,true,2,false),"Select Col1"),query(SORT(A2:B,1,true,2,false),"Select Col1"),0))},"Select Col1,Col2 where Col3<3"))
alternative formula:
=QUERY(SORT({{A2:B}\MAP(A2:A;B2:B;lambda(ax;bx;IFERROR(Rank(bx;Filter(B$2:$B;A$2:$A=ax);0);IFERROR(1/0))))};1;0;3;1);"Select Col1, Col2 Where Col3<3")
-
I am creating a scheduling system for my company. I have tried this a few ways and I am not getting anywhere. I need the corresponding date that an employee is off to show "TRUE". Since I am using VLOOKUP for this, I am only getting the first value. I am using the following formula in cell F2.
=arrayformula(ifna(if(vlookup($E2:$E62,$A$2:$C$15,2,false)=F$1:L1,true,""),""))
I have highlighted the issue. Can someone take a look at this and point me in the right direction?
Sample spreadsheet: https://docs.google.com/spreadsheets/d/1e7b2aiGRH9Mm2mB2A_d4uavXQeCKrW3vXgMcnYtAfRM/edit#gid=0
use in F2:
=ARRAYFORMULA(IF(ISNUMBER(IFNA(VLOOKUP(E2:E, QUERY(QUERY({A2:B},
"select Col1,max(Col1) where Col2 is not null group by Col1 pivot Col2"),
"select Col1,Col3,Col5,Col4,Col2"), {2, 3, 4, 5}, 0))), TRUE, ))
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."
I'm looking for an efficient way to gather and aggregate some date in Google Sheets. I've been looking at the query function, pivot tables, and Index + Match formulas, but so far I've not found a way that brings me to the result I'm looking for. I have a set of data which looks more or less as follows.
The fields with an X represent irrelevant data which I don't want to show up in my end result. They only serve to illustrate that there are columns of data that I don't want in between the columns of data that I do want. The data in those columns is of varying types and of varying values per type, they are not actually fields with an "X" in it. Only the fields with numbers are of interest along with the related names at the top and left of those. The intent is to create a list that looks more or less like this.
I've highlighted those yellow fields because that data has been aggregated. For example, in the original file field D3 shows a relation between Laura and Pete with the number 1, and field L3 also shows a relation between Laura and Pete, so the number in that field is to be added to the number in the other field resulting in an aggregated total of 2 for that particular combination.
I would really appreciate any suggestions that can help me get to an elegant and efficient solution for this. The only solutions I can come up with would involve multiple "in-between" sheets and there just has to be a better way.
UPDATE:
Solved by applying the solution in player0's answer. I just had to switch around the order of Col1 and Col2 in the formula to get the table sorted the way I needed it. Formula looks like below now. Many thanks to both player0 and Erik Tyler for their efforts.
=INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&D1:N1&"×"&D2:N), "×"),
"select Col2,Col1,sum(Col3)
where Col2 is not null
and Col3 is not null
group by Col2,Col1
label sum(Col3)''", ))
try:
=INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&D1:N1&"×"&D2:N), "×"),
"where Col3 is not null and Col2 is not null", ))
update:
=INDEX(QUERY(SPLIT(FLATTEN(A2:A&"×"&D1:N1&"×"&D2:N), "×"),
"select Col1,Col2,sum(Col3)
where Col3 is not null
and Col2 is not null
group by Col1,Col2
label sum(Col3)''", ))
Given your current data set (which only appears to extend to Col N), place the following somewhere to the right of Col N:
=ArrayFormula(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(SPLIT(QUERY(FLATTEN(FILTER(IF(NOT(ISNUMBER(D2:N)),,D1:N1&"~ "&A2:A&"|"&D2:N),A2:A<>"")),"Select * WHERE Col1 Is Not Null"),"|"),"Select Col1, SUM(Col2) GROUP BY Col1 LABEL SUM(Col2) ''")&"~ "),,2)),"~ ",0,1))
It would be better if this were placed in a different sheet from the original data. Supposing that your original data sheet is named Sheet1, place the following version of the above formula into a new sheet:
=ArrayFormula(SPLIT(TRANSPOSE(QUERY(TRANSPOSE(QUERY(SPLIT(QUERY(FLATTEN(FILTER(IF(NOT(ISNUMBER(INDIRECT("Sheet1!D2:"&ROWS(Sheet1!A:A)))),,Sheet1!D1:1&"~ "&Sheet1!A2:A&"|"&INDIRECT("Sheet1!D2:"&ROWS(Sheet1!A2:A))),Sheet1!A2:A<>"")),"Select * WHERE Col1 Is Not Null"),"|"),"Select Col1, SUM(Col2) GROUP BY Col1 LABEL SUM(Col2) ''")&"~ "),,2)),"~ ",0,1))
This separate-sheet approach and formula allows for the original data to extend indefinitely past Col N.
I have the following table on Google Spreadsheet:
And would need to get the following transformation result:
I precise that for each vegetable i can have only 1 buy price, and 1 or several sell prices
I am pretty sure this can be achieved combining ArrayFormula() + Vlookup() but have not been able to find the right formula so far. Any help would be welcomed
Thanks in advance
Cheers
Yoann
try:
=INDEX(SPLIT(FLATTEN(QUERY(TRANSPOSE(QUERY(QUERY(
{A2:C, IF(B2:B="buy", CHAR(13)&C2:C, C2:C)},
"select Col1,max(Col3) where Col1 is not null group by Col1 pivot Col4"),
"offset 1", 0)),,9^9)), " "))