I want to sum in a column but this sum need to break if is a different day
here a small example google sheets
Found this but formula '=SUMIF(ARRAYFORMULA(MONTH(Sheet1!A2:A)),1,Sheet1!B2:B)'
Do You mean something like this ?
={"Total"; ArrayFormula(if(len(A2:A),if(match(A2:A, A2:A, 0)=row(A2:A)-1,sumif(A2:A,A2:A,B2:B),),))}
JPV, I'm wondering if your solution would only work if there were exactly two entries per date.
My suggestion (in C2):
=ArrayFormula(IF(INDIRECT("A2:A"&ROWS(A:A)-1)="","",IF(A3:A=INDIRECT("A2:A"&ROWS(A:A)-1),"",VLOOKUP(INDIRECT("A2:A"&ROWS(A:A)-1),QUERY(A2:B,"Select A, SUM(B) Where A Is Not Null Group By A Order By A Desc"),2,FALSE))))
try:
=ARRAYFORMULA(IF(COUNTIFS(A2:A, A2:A, ROW(A2:A), "<="&ROW(A2:A))=1,
IFNA(VLOOKUP(A2:A, QUERY(A2:B,
"select A,sum(B) where B is not null group by A"), 2, 0)), ))
Related
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))))
I am looking to build a formula that will check columns for a true value and if true return the first column name, in order...
Below is the formula I have been trying to build but it is not working as expected although I think I am close.
=ARRAYFORMULA(IF(HLOOKUP($A16,{Sheet1!$B$2:$E$5,Sheet2!$B$8:$E$11},{3,4,5},0)=TRUE,{Sheet2!$A$3:$A$5,Sheet1!$A$3:$A5,""))
Let me illustrate. Sheet 1 and Sheet 2 contain names with who has what (checkbox items). With a formula in cell B16 that will populate both to the right and down with all the names that contain a TRUE value in the looked up value (A:A).
Above image was manually typed in, the formula does not work at all.
Please help!
EDIT: Link to sheet
try:
=INDEX(IFERROR(VLOOKUP(A14:A, SUBSTITUTE(REGEXREPLACE(SPLIT(FLATTEN(
QUERY(SUBSTITUTE(QUERY(SPLIT(FLATTEN(
IF({B3:E5; B9:E11}=TRUE,
{B2:E2&"♦"&A3:A5&"♣"&ROW(A3:A5);
B8:E8&"♦"&A9:A11&"♣"&ROW(A9:A11)}, )), "♦"),
"select max(Col2) where Col2 is not null group by Col2 pivot Col1"),
" ", "♥"),,9^9)), " "), "(♣\d+)", ), "♥", " "),
SEQUENCE(1, COUNTUNIQUE(B2:E2, B8:E8))+1, 0)))
demo sheet
Here is another approach (similar to player0's, but different enough to warrant the separate answer:
=ArrayFormula(IFERROR(TRIM(SPLIT(VLOOKUP(FILTER(A3:A,A3:A<>""),REGEXREPLACE(SPLIT(FLATTEN(QUERY(QUERY(SPLIT(QUERY(FLATTEN({IF(Sheet1!B2:E<>TRUE,,Sheet1!B1:E1&"~|"&Sheet1!A2:A&",");IF(Sheet2!B2:E<>TRUE,,Sheet2!B1:E1&"~|"&Sheet2!A2:A&",")}),"Select * WHERE Col1 Is Not Null"),"|"), "Select MAX(Col2) where Col2 IS NOT NULL GROUP BY Col2 PIVOT Col1"),, 9^9)),"~"),"[,\s]+$",""),2,FALSE),","))))
I've added it into your spreadsheet in a new sheet ("Erik Help").
If you have more than two sheets' to include, just find this section of the formula and continue the pattern:
{ IF(Sheet1!B2:E<>TRUE,,Sheet1!B1:E1&"~|"&Sheet1!A2:A&","); IF(Sheet2!B2:E<>TRUE,,Sheet2!B1:E1&"~|"&Sheet2!A2:A&",") }
I have two tabs Product-Overview and Prices.
On the Prices-tab I would like to add my data and get an overview on the financials tab.
I was trying to use index-match, however if there are several values in the same month in my Prices-tab I am not sure how to sum the up?
I would like to get the following result:
Find below my minimum viable example as google sheet:
Google Sheet
Any suggestions how to do this?
delete column D and use this in D2:
=ARRAYFORMULA(IF(A2:A="";;TEXT(B2:B; "mm/yy")))
then you can do this:
=QUERY(Prices!A2:D; "select A,sum(C) where A is not null group by A pivot D")
and more advanced in O5:
=ARRAYFORMULA(IF(O1:1="";;IF(B5:B="";;
IFNA(VLOOKUP(B5:B; QUERY(Prices!A2:D;
"select A,sum(C) where A is not null group by A pivot D");
MATCH(TO_TEXT(O1:T1); QUERY(QUERY(Prices!A2:D;
"select sum(C) where A is not null group by A pivot D");
"limit 0"; 1); 0)+1; 0))*1)))
of course B5 can be:
=SORT(UNIQUE(Prices!A2:A))
then D5 can be:
=ARRAYFORMULA(IF(B5:B="";;"Product "®EXEXTRACT(TO_TEXT(B5:B); ".(\d+)")))
average N5 can be done like:
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(O5:100);
"select "&TEXTJOIN(","; 1; IF(B5:B="";;
"avg(Col"&ROW(O5:O)-ROW(O5)+1&")"))&""));
"select Col2"))
generating dates in O1 like:
=ARRAYFORMULA(ARRAY_CONSTRAIN(TRANSPOSE(UNIQUE(TEXT(ROW(INDIRECT(
DATEVALUE("1/11/2020")&":"&
DATEVALUE("1/11/2050"))); "mm/yy"))); 1; COLUMNS(O1:1)-1))
and years in O2 like:
=ARRAYFORMULA(IFNA(20®EXEXTRACT(O1:1; "/(\d+)")))
What you are looking for is the sumifs formula:
This will solve your problem, it is not an arrayformula, but it works if you drag it for the cells you want them to go.
=sumifs(
Prices!$C$2:$C;
Prices!$A$2:$A;$B5;
Prices!$D$2:$D;">="&if(isblank(N$1);date(year(O$1);month(O$1)-1;day(O$1));N$1);
Prices!$D$2:$D;"<="&if(isblank(O$1);date(year(N$1);month(N$1)+1;day(N$1));O$1)
)
Trying to understand if it is possible to apply ARRAYFORMULA to situations when QUERY is used in Google Sheets.
For example, I used QUERY for querying and aggregating a set of items, like so:
=QUERY($H$2:$I$17,"select sum(I) where H='"&A2&"' label sum(I) ''",0)
But in order to make that work across the spreadsheet, I will have to drag this formula down. There is also the ARRAYFORMULA thing, which is supposed to help with getting rid of excessive dragging, however it does not seem to work with QUERY, or am I just missing something?
A picture for a quick look:
And a shared file for the longer thinking:
https://docs.google.com/spreadsheets/d/1xOdqeESrFbrBknNYahSeF0ripA5fr2vVFQ-r--lkdA0/edit?usp=sharing
use this formula:
=QUERY(H2:I17, "select H,sum(I) where H is not null group by H label sum(I)''", 0)
and then you can do simple VLOOKUP like:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A, QUERY(H2:I17,
"select H,sum(I) where H is not null group by H label sum(I)''", 0), 2, 0)))
Here two method alternatively:
first ==>
=arrayformula(sumif(H2:H,"=" & unique(filter(H2:H,H2:H<>"")),I2:I))
second ==>
=arrayformula(
query(
filter({vlookup(H2:H,{A2:A,row(A2:A)},2,false),H2:I},H2:H<>"")
,"Select sum(Col3) group by Col1 label Sum(Col3) ''"
)
)
I'm trying to figure out the way to count the number of Draw for each team.
To count as a draw, a match had to be played (So no empty score value on both cells, and the team must appear in either column B or E, and the result must be "Draw")
Can anyone help me find the proper formulae? I already tried to use COUNTIFS but couldn't succeed.
=QUERY(FILTER({B2:B; E2:E}, {F2:F; F2:F}="Draw"),
"select Col1,count(Col1) group by Col1 label count(Col1)''", 0)
and F2 cell would be:
=ARRAYFORMULA(IF(E2:E<>"",
IF(C2:C=D2:D, "Draw",
IF(C2:C>D2:D, B2:B,
IF(C2:C<D2:D, E2:E, ))), ))
Use Two COUNTIFS() and add them together:
=COUNTIFS(B:B,"Real Madrid",F:F,"Draw")+COUNTIFS(E:E,"Real Madrid",F:F,"Draw")