I have date in one column and data in another from jan 2017 to Dec 2022.
I want to find sum of data month wise.
attaching file. Currently doing it manually. Any work around, array or something. Help.
You can try with a QUERY like this:
=QUERY({INDEX(EOMONTH(A:A,0)),C:C},"SELECT Col1,Sum(Col2) where Col2 is not null group by Col1 format Col1 'MMM-YYYY'",1)
within sheets you can try:
=QUERY({INDEX(IF(LEN(A9:A),EOMONTH(A9:A,),)),C9:C},"SELECT Col1, SUM(Col2) Where Col1 IS NOT NULL GROUP BY Col1 LABEL SUM(Col2) '' FORMAT Col1 'MMM YY'")
Related
Hello, please help me
How to split sum by month? in googlesheets ?
Try:
Formula in J3:
=INDEX(QUERY({TEXT(B3:B,"YYYY-MM"),H3:H},"Select Col1, sum(Col2) where Col2>0 group by Col1 label Col1 'month'"))
Use this formula
= ArrayFormula(
{ TEXT(DATE(YEAR(TODAY());UNIQUE(MONTH(A3:A));DAY(TODAY())); "mmmm yyyy")\ IF(SUMIF(MONTH(A3:A); UNIQUE(MONTH(A3:A));H3:H)=0;;TEXT(SUMIF(MONTH(A3:A); UNIQUE(MONTH(A3:A)); H3:H); "Rp#,###"))})
Formula:
=ARRAYFORMULA(SUMIF(MONTH(A3:A); UNIQUE(MONTH(A3:A)); H3:H))
Explanation:
MONTH(A3:A) extracts the month from the dates in column A
UNIQUE(MONTH(A3:A)) finds the unique months from this list
SUMIF() takes the month of each row as the range for the summation, the list of unique months as the criteria, and then the total values H3:H as the range to sum.
ARRAYFORMULA() expands it to all rows below
Use QUERY() function with date columns so that we can sort if needed. Use EOMONTH() to make group by month.
=QUERY({INDEX(IF(B2:B="",,EOMONTH(B2:B,0))),E2:E},"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label Col1 'Month', sum(Col2) 'Total'
format Col1 'MMM-YYYY'")
I am using Google Sheets.
I have names in first column, dates in first row, and numbers for each name/date.
I want to return the name and sum of numbers for the person who's sum of numbers is the largest (within date range.)
A cell formula for this would be better than a script.
It sounds straight forward but am going in circles and would appreciate help. Thanks Newman
Thank you.
try:
=INDEX(QUERY(SPLIT(FLATTEN(A3:A&"♦"&FILTER(B3:F, B2:F2>="2021-10-07"*1, B2:F2<="2021-10-13"*1)), "♦"),
"select Col1,sum(Col2) where Col2 is not null group by Col1 order by sum(Col2) desc label sum(Col2)''"))
and for just 1 record:
=INDEX(QUERY(QUERY(SPLIT(FLATTEN(A3:A&"♦"&FILTER(B3:F, B2:F2>="2021-10-07"*1, B2:F2<="2021-10-13"*1)), "♦"),
"select Col1,sum(Col2) where Col2 is not null group by Col1 order by sum(Col2) desc label sum(Col2)''"), "limit 1", 0)
here I want to know can we find the total peoples present on that specified date? that if we enter the date on the next sheet we need to display the count of peoples present on that day. An example is there on the sheet 2.
https://docs.google.com/spreadsheets/d/1TxScKc0NT2pB9ytpyMcq99nYmirS5NAPnRGNtACyaeE/edit#gid=0
thanks in advance
use:
=QUERY({Sheet1!A2:B},
"select Col1,count(Col2) where Col2 is not null group by Col1 label count(Col2)''")
update:
=ARRAYFORMULA(IFNA(VLOOKUP(A2:A, QUERY({Sheet1!A2:B},
"select Col1,count(Col2) where Col2 is not null
group by Col1 label count(Col2)''"), 2, 0)))
I'm looking for a formula, =query possibly, that will turn this:
Into this:
I used the following formula successfully to get the AFTER picture, but I can't get the counts. I tried using concatenate but there isn't a way to do that to each item in the array. Maybe there is a way to do this using a query?
=transpose(split(join(",",unique(C1:C98)),","))
And here's my flavour of it, which also needs to be dragged to the right, to fill the other columns:
=ARRAYFORMULA(QUERY(
{UNIQUE(A$2:A) & " - " & COUNTIF(A$2:A,UNIQUE(A$2:A))},
"where Col1<>' - 0'",0))
Yes, you can use query to get the unique values and counts then join the two columns
=ArrayFormula(index(query(A2:A,"select A,count(A) where A is not null group by A label count(A) ''"),0,1)&"-"&index(query(A2:A,"select A,count(A) where A is not null group by A label count(A) ''"),0,2))
Apologies, in order to drag it across you would have to put:
=ArrayFormula(index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,1)
&"-"&index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,2))
Try the following in cell A2 and drag to the right.
=ARRAY_CONSTRAIN(ArrayFormula(IFERROR(CONCAT(UNIQUE(A2:A99)&" - ",
ArrayFormula(COUNTIFS(A2:A99,UNIQUE(A2:A99)))))),COUNTUNIQUE(A2:A99),1)
Also using a query
=ArrayFormula(index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,1)&"-"&
index(query({A2:A},"select Col1,count(Col1) where Col1 is not null group by Col1 label count(Col1) ''"),0,2))
The only difference is that using the first formula you maintain the names within the order they appear, while using the query they get sorted alphabetically.
Functions used:
ARRAY_CONSTRAIN
ArrayFormula
IFERROR
CONCAT
UNIQUE
COUNTIFS
COUNTUNIQUE
When I use the format that I left below, returns in error, I know that something is missing adjusting in relation to WHERE AND... But I could not fit to supply the error.
I would like some help knowing what I missed.
"select Col1,Col2,Col3 where Col1 is not null Order by Col1, Col2 AND Col1 > date'"&TEXT(today()-1,"yyyy/mm/dd")&"'"
The date and time for Col1 and Col2 are like this:
With this formula, I hope I can filter the imported data only for those that have the date of the current day or tomorrow and that today's games are higher than the current time.
Link to spreadsheet:
https://docs.google.com/spreadsheets/d/15T4UPVtEHv43DLomKcTmdaPuGWMsBUoO7bLvlOhab4k/edit?usp=sharing
Formula set in Página1 G2
it may look like you can combine parameters as you like but there is a specific order that needs to be followed:
respectively joining operator like and needs to be proceeded by parent parameter where:
Try:
"select Col1, Col2, Col3 where Col1 >='"&TEXT(TODAY()-1,"yyyy-mm-dd")&"' and Col1 is not null Order by Col1, Col2"
This returns 78 records