Arrayformula with SUMIFS does not dropdown - google-sheets

I am trying to solve this problem for a while already. I have read some questions here, but none of them solved my problem.
I have a table with some stock data and I am trying to calculate the average price until that moment using an ARRAYFORMULA, what I want is in ColH, but my ARRAYFORMULA does not dropdown automatically and honestly I can't understand the reason for it.
PrintScreen
https://docs.google.com/spreadsheets/d/1sRDNCyWK1LItqETYoWSOV9eiEI4mySDetlBcbupwbvk/edit?usp=sharing
The formula I am using is:
=ArrayFormula(SUM(FILTER($G$2:G2;$C$2:C2="Buy";$D$2:D2=INDEX($D2:$D;1);$A$2:A2=INDEX($A2:$A;1)))/SUM(FILTER($E$2:E2;$C$2:C2="Buy";$D$2:D2=INDEX($D2:$D;1);$A$2:A2=INDEX($A2:$A;1))))
Why this is not working? I have tried with SUMIFS as well but it did not work.

try:
=ARRAYFORMULA(QUERY(SPLIT(FLATTEN(IF(
INDIRECT("D2:D"&MAX(IF(C2:C="buy"; ROW(C2:C))))=IF(ROW(
INDIRECT("C2:C"&MAX(IF(C2:C="buy"; ROW(C2:C)))))>=TRANSPOSE(ROW(
INDIRECT("C2:C"&MAX(IF(C2:C="buy"; ROW(C2:C)))))); TRANSPOSE(
INDIRECT("D2:D"&MAX(IF(C2:C="buy"; ROW(C2:C))))); ); ROW(
INDIRECT("C2:C"&MAX(IF(C2:C="buy"; ROW(C2:C)))))&"×"&
INDIRECT("G2:G"&MAX(IF(C2:C="buy"; ROW(C2:C))))&"×"&
INDIRECT("E2:E"&MAX(IF(C2:C="buy"; ROW(C2:C)))); )); "×");
"select sum(Col2)/sum(Col3)
where Col2 is not null
group by Col1
label sum(Col2)/sum(Col3)''"))

Related

Unpivot - Ignore if value is null

in Google Sheet, I use this formula to unpivot a table:
=arrayformula(SPLIT(FLATTEN(IMPORTRANGE("https://docs.google.com/spreadsheets/d/";"Foglio1!A2:A999")&"|"&IMPORTRANGE("https://docs.google.com/spreadsheets/d/";"Foglio1!AQ1:BB1")&"|"&IMPORTRANGE("https://docs.google.com/spreadsheets/d/";"Foglio1!AQ2:BB999"));"|"))
The data structure is like in the screenshot: the problem is that the unpivoting create row also when (for example) Alpha in Project A is null.
How can i fix this problem, creating unpivoted rows only if the value in the cell is > 0?
Many thanks mate!
Screenshot
Wrap the formula in a query(), like this:
=query( arrayformula(...); "where Col3 is not null"; 1 )

Get the last value of a column when another has a specific value

In this great community I always like to learn with what I am discovering, that is why I would like to know if this solution that I have found can be done in a better way.
I have two columns where I am introducing values and I get a value from a column according to the condition of the first one.
I do this with the following google sheets formula:
=INDEX(filter(Blockchains!F$2:F,Blockchains!E$2:E=VALUEA),ROWS(filter(Blockchains!F$2:F,Blockchains!E$2:E=VALUEA)),1)
Is there a way to make it better?
try:
=INDEX(QUERY(SORT(E:F, ROW(E:E), ), "where Col2 = 'VALUEA'", ), 1, 1)
better safe than sorry:
=INDEX(QUERY(SORT(E:F, ROW(E:E), )&"", "where Col2 = 'VALUEA'", ), 1, 1)

Google sheets: filter columns if rows are not blank

I am trying to figure out a formula to show all the projects for which there are hours assigned. From a first query I get the following output, listing projects and assigned hours:
Now I want to filter for projects with assigned hours. Since I want to add this to my existing query, I cannot use A1 notation. Any idea? :)
Try
=unique(query(arrayformula(split(flatten((A1:C1&"~"&A2:C)),"~")),"select Col1 where Col2 is not null"))
transpose({transpose({A1:C1}),query(transpose(query({A2:C},"select "&textjoin(",",1,index("sum(Col"&sequence(1, 3,1)&")"))&"), "select Col1 where Col2 >0")})
I solved the issue with this formula. But yours also worked #Mike Steelson -thanks!
Here's another way you can do that:
=flatten(filter(A1:C1,trim(query(A2:C,,9^9))<>""))

Google Sheets most frequent and just one value

I'm trying to count the number of most frequent text in a column, I have this formula that I used before in excel...
=INDEX(E9:E18,MODE(IF((E9:E18<>"")*ISNA(MATCH(E9:E18,$B$1:$B1,0)),MATCH(E9:E18,E9:E18,0))))
This works, but when I get some repited value shows #N/A
Here is an capture from this I would like to know how can I resolve this I tried with
=INDEX(E9:E18,MODE(IF(AND(E9:E18<>"")*ISNA(MATCH(E9:E18,$B$1:$B1,0)),MATCH(E9:E18,E9:E18,0))))
But I get lost trying to put a condition like only one value = value
Some help or code that I could use?
So this is my problem
With Office 365:
=INDEX( SORTBY(UNIQUE(A1:A10), COUNTIF( A1:A10, UNIQUE(A1:A10) ),-1), 1 )
Oops - i just saw the Google sheets edit.
For most frequent:
=INDEX( SORT(UNIQUE(A1:A10), COUNTIF( A1:A10, UNIQUE(A1:A10) ),0), 1 )
For Just One Value:
=FILTER(UNIQUE(A1:A10),COUNTIF(A1:A10,UNIQUE(A1:A10))=1)
try:
=QUERY({A:A};
"select Col1,count(Col1)
where Col1 is not null
group by Col1
label count(Col1)''")

Sum Up Values from the Same Date In Google Sheets

I have a sheet that I am using to track wordcount over multiple writing projects. I'd like to have it automatically add up the words I've written that day. I write in multiple sessions, and each session is its own row on the sheet.
I continue to add onto the sheet during the month, so using DATE won't work unless I want to manually change the formula every time a new day starts. I'd really appreciate whatever help could be given.
Here is the link to the sheet--this one is a copy, so feel free to poke around as needed and don't worry about messing it up :) https://docs.google.com/spreadsheets/d/1mNrJzSDpfTRuvZSRpt7BQn0HfA2mdhZzTym2DqNlXZU/edit?usp=sharing
delete all in column I and use in row 1:
={"Daily Total"; INDEX(IFNA(VLOOKUP(IF(COUNTIFS(A2:A, A2:A,
ROW(A2:A), "<="&ROW(A2:A))=1, A2:A, ), QUERY({A2:A, H2:H},
"select Col1,sum(Col2) where Col2 is not null group by Col1"), 2, 0)))}

Resources