I need to calculate daily profit based on the date. What formula should I use here? Thank you!
try:
=QUERY({A2:B};
"select Col1,sum(Col2)
where Col1 is not null
group by Col1
label sum(Col2)''")
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 want to make two columns one that has date and the other that has sum for the number of violations occurred on that day. Have a look at the data below.
use:
=QUERY({B:C}; "select Col1,sum(Col2) where Col1 is not null group by Col1 label sum(Col1)''")
I have a spreadsheet that has data in one column (H2:H500) and dates in another column (F2:F500). I would like a sum of the total number in the past work week (Monday-Friday). I'm not sure if I need to use =CountIfs or what. Any help would be greatly appreciated!
=COUNTIFS(F2:F500,WEEKNUM(TODAY(),1),H2:H500, "<>")
...doesn't seem to work. Am I close?
=COUNTA(QUERY({A2:B},
"select Col1
where Col2 is not null
and Col1 >= date '"&TEXT(DATE(YEAR(TODAY()),1,1)-WEEKDAY(DATE(YEAR(TODAY()),1,1),3)+7*
(WEEKDAY(DATE(YEAR(TODAY()),1,1),3)>3)+7*(WEEKNUM(TODAY())-2),"yyyy-mm-dd")&"'
and Col1 <= date '"&TEXT(DATE(YEAR(TODAY()),1,1)-WEEKDAY(DATE(YEAR(TODAY()),1,1),3)+7*
(WEEKDAY(DATE(YEAR(TODAY()),1,1),3)>3)+7*(WEEKNUM(TODAY())-2)+4,"yyyy-mm-dd")&"'"))