I don't think this problem is solvable but I figured I would ask.
Data:
DateDim table with 1 row for every date. Columns = date
Sales table with 1 row for every sale. Important columns = id, sales_date
tables relate on date = sales_date
Plot:
I am plotting count of sales for each date, with date on the x-axis and count([id]) on the y-axis.
Problem:
I need a dynamic x-axis. If I filter date for less than a month I need days on the X-axis, but if I filter greater than a month I need month-year on the x-axis.
I accomplished this with daterunc function.
If endDate - startDate < 30
then daterunc('day', [date])
else if endDate - startDate >= 30
then daterunc('month', [date])
end
This works nice except for one issue: missing values. If I use the date as the axis, I can right click the date and select "show missing values" which will correctly plot 0 on days with no sales.
But the calculation above does not have a 'show missing values' option. So the plot does not show zeros when I use the calculation.
Is it possible to modify the above calculation to show missing values?
Related
I have an array of dates and values and want to calculate in a formula at what date a certain value will be reached or be bigger.
Example:
1/1/2022 10
1/10/2022 13
1/20/2022 16
1/30/2022 19
At what date will 50 be reached?
GS has formulas to forecast the value for a date, but I know the value - I need the date.
Any help appriciated.
A4 is the first date a4:a7 is the dates, b4:b7 is the values, 365 is how many days I want to plot out into the future and 50 value is the number you requested to find the date.
=vlookup(50,arrayformula({Growth(B4:B7, A4:A7-$A$4, sequence(365)-1),sequence(365)+$A$4-1}),2)
50 will be reached on 10th May 2022...
try TREND function:
=TREND(A1:A4; B1:B4; 50)
or FORECAST:
=FORECAST(50, A1:A4, B1:B4)
or GROWTH:
=GROWTH(A1:A4, B1:B4, 50)
or LOGEST, LINEST based on your specific project needs
So I'm currently setting up a sheet that records weekly numbers. I'd love to have something that summarizes the totals (money in, loss, etc) by month. So if the week = 4/4/0 this is April (4) and is calculated just by a drop-down of months. Is such a thing possible in Sheets? I don't need the formula just the clue, really.
Update:
I found something similar:
=SUMIFS($N$7:$N$11,$M$7:$M$11,">="&S8,$M$7:$M$11,"<="&EOMONTH(S8,0))
N7:N11 is amount
M7:M11 is date
S8 is the date I'm querying for
The issue I have with that (^^) formula is that it wants me to present the date as D-MONTH-YYYY
but I'd love the date to just be the MONTH
You can set the column to show just the month by setting its format:
and creating a "Custom date & time"
Alternatively, you can use text to represent the months and convert them to number representation using MONTH(S8&1)
Then, you can do some funky way of converting the "month" to "date" using DATE(YEAR, MONTH(S8&1), 1), where "year" is the year you're querying for.
To sum it up, the formula from your question might look something like this:
=SUMIFS($N$7:$N$11, $M$7:$M$11, ">="&DATE(2022, MONTH(S8&1), 1), $M$7:$M$11, "<="&EOMONTH(2022, MONTH(S8&1), 1),0))
I have a date range and a corresponding value.
On a the right-hand side of this data table, I want to separate the value monthly.
Available Data
Result Expected
*I have the limits of the date range any row can have. Ex: Mar 1st to Jun 30th.
I can take the number of days in a month and divide the value by that to get the value to fill in.
Problem is automatically deciding the cells which needs to be filled and which has to be marked as 0.
The solution I'm looking for is a formula that can be dragged into many more months.
My approach was to check at each cell if the Month Code("Mar", "Apr", "May"....etc) includes in the date range in A and B columns.
I have searched ways to check this and have failed. Is there a way to check if a month includes within a particular date range?
Or is there any other way I can fill the cells from D2 to G6?
*Actual scenario has more than 4 months and more than 6 Rows of data.
This is a formula giving the exact amounts for first row - not sure if that is what you want though:
=(max(0,min($B2,eomonth(datevalue("1-"&left(D1,3)&"2020"),0)))-max($A2,datevalue("1-"&left(D1,3)&"2020"))+1)*$C2/($B2-$A2+1)
Alternatively
=if(min($B2,eomonth(datevalue("1-"&left(D1,3)&"2020"),0))-max($A2,datevalue("1-"&left(D1,3)&"2020"))>=0 [your formula] ,0)
I have a column with month day numbers, so 20 means the 20th of the month.
I want to know how to check if a value in this column, say 20 is more than or less than today's month day.
I would use conditional formatting to color the cell in red if that day had not passed already.
What I tried to do was set a cell with today's date:
=TODAY()
Then based on this calculate if the month day was less than or greater by using this:
=DATEDIF(F2, "MD")
I was hoping this wold return a number which I could then do a compare with but this is wrong and I am not sure if what I want to do is even possible.
I have read through the documentation and Stackoverflow but I cannot find any close examples.
Thank you.
If you want to check the day of the month you need to extract exactly that.
If your date is in Cell A1 and your threshold (20) in A2 the conditional formatting formula to check if the date has not passed yet would then go:
=DAY(A1) < A2
I'm trying to set up a Google Sheet for volunteers at the local dog shelter. The idea is to have an auto-updating spreadsheet that shows at a glance which dogs really need to be walked, in two ways:
conditional formatting the rows with color based on time elapsed:
red if it's been >6 hours since their last walk,
yellow for 3-6 hours, or
green if they were walked <3 hrs ago.
auto-sorting the rows so that the dogs that have gone the longest are always at the top of the list, and when they get walked, they go to the bottom of the list.
Here's where I'm at.
Problem 1: I'm trying to calculate time elapsed by using the NOW() function (which returns the current date and time), minus the time of the last walk. The problem is that if you only enter a time, Google apparently assumes the date is 12/30/1899. So if I put in 8:00 am, and the current time based on NOW() is 4:00 pm, instead of returning 8:00 hours, it calculates the the duration as 10,000,000+ hours that have elapsed since 8:00 am on December 30, 1899 up to the current date and time. (Similar problem discussed here).
If I keep the output cells in the HH:MM format, it'll initially look OK, because it'll just return the HH:MM as 8:00, BUT I can't use that because then the conditional formatting won't work - it's still actually calculating the 10,000,000 hours since 1899. So I can't set duration values for red/green/yellow because all the output values will be slowly increasing every day we get further away from 1899, meaning I would have to reset the ranges daily.
Obviously I could work around this by always including the time and date, but the idea is to have a spreadsheet that is idiot-proof so that any volunteer can use it by just adding the time they walked the dog. It won't work if they have to input the date too.
Problem 2: Assuming I can get the above to work, how can I set it up so the table automatically sorts itself after any change (i.e. when a dog gets walked and the entry gets updated)?
Help?
Please try:
Problem 1
Green is easy, just format all your data that way with standard fill (CF will override this where applicable).
Select A1 and apply a Custom formula is of:
=and($D1<>"",timevalue(now())>$D1+6/24)
with colour Red and Range A:E
Repeat (the order of these two is important):
=and($D1<>"",timevalue(now())>$D1+3/24)
with colour Yellow and Range A:E.
Save rules and close window.
Problem 2
Create a pivot table by selecting ColumnA:E (may have to get rid of some content present low down in the sheet first) and Data > Pivot Table Report..., to Rows Add field Dog name (do not Show totals), to Values Add field Time since last walk and Summarise by:SUM. Name the sheet PT.
In say J2 of your other sheet (not PT) enter:
=query(PT!A:B, "Select * order by B desc ")
May be worth noting that without the day part there might be problems where times span midnight - if you have walkers with insomnia?!
For the autosorting, I found a script elsewhere on stackoverflow and modified it slightly for my purposes:
function onEdit(event){
var sheet = SpreadsheetApp.getActiveSheet();
if(sheet.getName()=='Sheet1'){
var editedCell = sheet.getActiveCell();
var columnToSortBy = 4;
var tableRange = "a2:f91";
if(editedCell.getColumn() == columnToSortBy){
var range = sheet.getRange(tableRange);
range.sort( { column : columnToSortBy, ascending: true } );
}
}
}