Average of cell content based on day of month - google-sheets

I'm attempting to get an average number of calls/day based on yesterday's date.
My initial formula looks like this: =round(average(C24/3),2), where:
C24 = the total number of calls,
/3 = diving the contents of C24 by yesterday (assuming yesterday was the 3rd of the month),
,2 = rounding answer to 2 decimal places.
The formula itself works fine, but I have to go in daily to change the 'date' (/3, in my example).
Any suggestions as to how I can automate this formula so as to not have to go in to change the day of the month every day?
(for what it's worth, i tried using =round(average(C24/today()),2), but get a divide by zero error. Not sure what else to try. I also googled rolling averages/moving averages, but that didn't seem to help either.)

Use DAY and TODAY.
=DAY(TODAY()-1)
So
=ROUND(AVERAGE(C24/DAY(TODAY()-1)),2)

Related

Tableau: how to create calculated field for previous day value

I have created a monthly calendar in tableau that tracks enrollment sign ups for a business's rewards program. What I am trying to do is show the day over day % change between enrollment values. In this specific scenario, I am trying to find the % change between 371 to 499. However, to do this, I believe I first need to create a calculated field for the prior days value, so that I can then use the day over day % formula for all other values. Does anyone have any advice for this particular scenario?
I have tried using the datediff function, amongst other calculated fields, with no luck so far. I want to created a calculated field that will retrieve all "enrollment" values but only for the previous day, so that I can then use the "100*((final-initial)/initial) calculation to calculate the day to day % difference.
You can try this function. I think this might be the calc you need.
(ZN(SUM([Distance])) - LOOKUP(ZN(SUM([Distance])), -1)) /
ABS(LOOKUP(ZN(SUM([Distance])), -1))
You might have to play with the sign to get the result you want. Let me know if that doesn't work.

Time format in Google sheets

I have a 2 columns. One with a planned time of departure and another with actual time of departure. Up until a few days ago, if there was a delay, the difference would read as a negative number. For example, if the planned time was 8:00AM and the actual time was 8:21AM, the 3rd column showed a delay as "-00:21:00"), but now the duration of the delay is displayed as 24:00:00 minus the number of minutes of the delay, as shown in this snippet:
Fortunately, any/all formulas still read and process the values, so this is really just a cosmetic issue for anyone who wants to glance at the raw data.
sounds like the formatting got reset. select your Delayed column and change the format to Duration

Sum of values generated by ARRAYFORMULA() is incorrect (Google Sheet)

I have a sheet used to calculate worked time. The aim is to sum up the hours and divide them in "regular" ones (up to 8h per day) and "overtime" ones (anything more than 8h per day). Each date has to have two rows(the second one is hidden by default), as there are multiple places I can work at, but the time calculated should be summed. Also, time worked on Saturday and Sunday should always be counted as overtime.
Screencap here.
The problem I have is with calculating overtime hours.
Regular hours are generated by:
=arrayformula(IFS(
WEEKDAY(A3:A70; 1)=1;0;
WEEKDAY(A3:A70; 1)=7;0;
E3:E70+E4:E70>8;8;
E3:E70+E4:E70<=8; E3:E70+E4:E70))
They are summed by =SUM(IFERROR(G3:G71;0)), which works just fine. Overtime hours are generated by:
=arrayformula(IFS(
WEEKDAY(A3:A70; 1)=1;E3:E70+E4:E70;
WEEKDAY(A3:A70; 1)=7;E3:E70+E4:E70;
E3:E70+E4:E70>8;E3:E70+E4:E70-8;
E3:E70+E4:E70<=8; 0))
And summed similarly by =SUM(IFERROR(H3:H71;0)) in H72. However, it returns a wrong value - in the sample sheet, it is 57 instead of 7
If I select the summed range, the tooltip shows the correct sum (7). If I add/remove the decimal place or change the formatting in H72, it suddenly changes to the correct one, too. However, when any new data is added (i.e. hours form a new day), it goes back to showing incorrect values.
It is not a simple display error, because the values are then imported by another sheet via =IMPORTRANGE and it imports those wrong values.
Any idea how to fix it?
Sample sheet here
try in H72:
=INDEX(SUM(IFERROR(1*H3:H71;0)))
update:
=INDEX(SUM(IFERROR(FILTER(1*H3:H71; MOD(ROW(H3:H71)-1; 2)=0); 0)))

How do I calculate average tons per hour by driver in Google Sheets?

https://docs.google.com/spreadsheets/d/1SiUfqrJNHPAYjibeNBdzWQEcuzka5srf7mSHAv_bn5k/edit?usp=sharing
What would a formula look like to calculate the average tons per hour by driver in this example spreadsheet? Correcting for long times or even days between loads.
We're being charged on an hourly basis for freight so I'd like to figure out which drivers are the most efficient.
It's been tricky because the only concrete source of information we have is the scale tickets. So if they only do a single load in a day or go several hours between loads then the data would be skewed if you use a simple metric like time elapsed.
Also, I'll need the time elapsed between rows (not just the difference between Time In and Time Out) unless that time is > 1.5 hours. So something like:
=(TIMEVALUE(E3)-TIMEVALUE(D2))*24
...With some added logic to not include anything over 1.5 hours.
If a pivot table would be better than a lengthy formula, that's fine with me.
Here's an example for some added context: Driver Cody goes to Farm Nic to receive a load of hay, then comes back to the weigh station (Ticket, Time In, Gross are then determined), dumps the load, comes back to weigh again empty (Tare, Net, and Time Out are determined here), and goes back to Farm Nic until all the hay is harvested. Then it's on to Farm Zach and Farm Williams to repeat the process. There are several Drivers going at a time, which can be seen if the spreadsheet is sorted by Ticket. My goal is to figure out how many Tons each driver delivers per hour. The time elapsed would include the time between Tickets, because Time In and Time Out just show the time elapsed between coming in with a load of hay and leaving to go back to the field. To get a true measure of tons delivered per hour, you'd need to include the time between tickets, but also remove any instance where that time is greater than 1.5 hours. That will account for circumstances where the Driver isn't working and we aren't being billed, such as during equipment breakdowns.
I'm not much of a formulas guy so I hope this suffice your needs.
First I added a column to your sheet, to calculate how many amount of hours is taking for every single row, to do that I made use of the TIMEVALUE function:
=(TIMEVALUE(E2)-TIMEVALUE(D2))*24
Now you just need to get all the driver's hours and tons and make the quotient total_tons / total_hours. For that they may be some other functions that would do the job, myself I have used QUERY:
=QUERY(Sheet1!A:M, "select C, sum(I), sum(M), sum(I) / sum(M) group by C", 1)
I think pretty straightforward query, group all the data by C (Driver's name) and then sum the column I (tons) and the column M (hours).
With the following result:
The format may be a little off but you can change it as mush as you want. You can copy or play with the sheet
EDIT
After you change your requirements I made a change to my formula to calculate the hours worked:
=IF(
AND(
C3=C2,
A3=A2,
IFERROR(
(TIMEVALUE(E3)-TIMEVALUE(D2))*24) <= 1.5,
TRUE
),
(TIMEVALUE(E3)-TIMEVALUE(D2))*24,
(TIMEVALUE(E2)-TIMEVALUE(D2))*24
)
Let me explain here, before there was a much simpler formula but now having multiple rows that we need to check makes the formula more lenghty.
First with the IF and AND statement we check if the next row has:
The same day (A3=A2)
The same Driver (C3=C2)
Less than an hour and a half of difference (TIMEVALUE(E3)-TIMEVALUE(D2))*24) <= 1.5)
And also because the last row throws an error trying to TIMEVALUE an empty column I had to add the IFERROR
After that the TRUE condition (same day, same driver, under 1.5h hours difference) will calculate from the current Time in (D2) to the next Time in (D3):
(TIMEVALUE(D3)-TIMEVALUE(D2))*24
And in the FALSE statement we do the same we were doing before:
(TIMEVALUE(E2)-TIMEVALUE(D2))*24
The QUERY function stays the same. And the results have decreased drastically:
If you have any doubts you can go ahead and see the sheet

How to calculate average calls "timestamps" per day on Google Sheets

I need help calculating the average number of calls I receive per day on Google Sheets. I can use your help.
Specifically, I want to calculate average calls per day [count: timestamps] for weekdays and weekends, respectively.
Here is the link to the Google Sheet: https://docs.google.com/spreadsheets/d/1UnHxSuQeFcKWIYrZxHrKQFJQ0TNekNAGrlvY-CyfYdU/edit?usp=sharing
I have found several links that come close to the solution but nothing that solves it, e.g. http://yogi--anand-consulting.blogspot.com/2013/05/yogifrom-timestamp-column-compute.html
Thank you in advance!
The question has not been asked very well, it important to show your attempts and specifically what you're look for. But none the less:
Create a separate column in call sheet E:E with the formula =weekday(a1) this will convert your date into a day of week number (1 through 7). From that, use sum if =SUMIF(F:F,"<=5") for your weekday, and=SUMIF(F:F,">=6")` for weekwend

Resources