Tableau: how to create calculated field for previous day value - field

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.

Related

Trying to only SUM values in one column based on if the adjacent cells in another column contain a formula

So I'm creating a Google Sheets doc that contains my hours and overtime for an hourly position I have, and how much overtime I'll need to make the amount of money I need to make to survive.
In addition to this I am also trying to track my hours so I can track the actual amount of money I'm making.
So I have a projected clock out time in Column B that uses a formula to tell me what time I need to ideally clock out at based on how many hours I need and what time I clocked in at. When I clock out, I enter the actual time I clocked out at.
In Column C I have the total amount of hours I worked that day, formatted in duration based on the difference between the value in Column A and Column B. If I haven't entered in a value in Column B, it shows me the ideal amount of hours I need that day.
I want to calculate my actual hours worked per week as I'm working that week, so I need to ONLY sum the values in Column C if the adjacent value in Column B is NOT a formula. So I need it to sum the values in column C if I've entered the actual time that I clocked out at in column B.
I've looked up this question and tried multiple solutions I've found here, even tried troubleshooting with ChatGPT, but most are just trying to sum the range that contains the values/formula, and not summing a different column based on if another column has formulas or not.
There seems to be a lot of posts that come super close but don't seem to work for how I need this to work.
Edit: Here is the example sheet.
So F3:F6 are values that have been manually entered, while F:7 has been calculated by a formula.
I need H9 to sum the values of H3:H7, but only the values adjacent to the times in the F column that have been manually entered. In this example, I need it to sum H3:H6 and ignore H7 until I enter a time and remove the formula in F7.
try:
=SUMPRODUCT(MAP(F3:F7,LAMBDA(z,IFNA(FORMULATEXT(z),1))),H3:H7)
You may filter and check if there is a formula with FORMULATEXT. If there isn't it will throw a #N/A error. Then with ISNA it will keep the values in which its adjacents did'nt have a formula:
=SUM(FILTER(C:C,BYROW(B:B,LAMBDA(b,ISNA(FORMULATEXT(o))))))

Repeat cell values and increment them afterwards

I'm trying to set up a structure in a sheet that allows for a date value to be incrementally (monthly) increased from a given start date. However, I also want each month to be repeated x times before it moves on to the next month, which should then also be repeated x times before moving on, and so on, until a given end date.
I've created this sheet to exemplify my desired output.
In the Example tab, I have a list of names (Sales reps) which, in this case, correspond to the "x" I mentioned previously. This means that I would like each date value to be repeated the same number of times as there are sales reps, before moving on to the next month and repeating it again the same number of times as there are sales reps. This also means that, if I increase the number of sales reps at some point, that should also be reflected in the number of times that a month is repeated. Also, the start and end dates should match the values in D3 and D5.
In columns D and E in the Example tab, I just wrote the kind of behaviour I'm looking for in static values. Can anyone help me fill in the Desired solution tab with a formula that automatically achieves that? That would be much appreciated 🙏🏻😃
EDIT: THINGS TRIED SO FAR
I created a new tab called Undesired solution where I show a hacky workaround that I tried, but that I would like to keep away from. The main reason for that is that, if the number of sales rep was to change:
I would have to manually update the first few cells of column F
I would have to manually update the formula used from G5 onwards
Here's how it looks filled with an array formula. I'm using counta() to get the number of names and month() to get the difference between start and end date in months, then applying sequence with int and mod to get the index of the required date and name, finally applying edate and vlookup to get the actual date and name.
=ArrayFormula({edate(D3,int(sequence(COUNTA(B3:B)*(month(D5)-month(D3)+1),1,0)/COUNTA(B3:B))),
vlookup(mod(sequence(COUNTA(B3:B)*(month(D5)-month(D3)+1),1,0),COUNTA(B3:B)),{sequence(rows(B3:B),1,0),B3:B},2)})

Find Number of Days in Current Month That Fall Between Date Range In Google Sheets

I'm trying to come up with a function that will calculate a monthly budget from within a specified date range. I tried to use SUMIFS but I can't figure out how to isolate a specific month within the range.
Example:
We have a sheet with Google Ad campaigns, with a row for each campaign.
We are running one Google Ad campaign (A) from 2/15/20 to 5/15/20 with a total budget of $3000 from which I calculate a daily budget of $33.33.
We are running a second campaign (B) from 5/15/20 to 8/15/20, also with a budget of $3,000, from which I calculate a daily budget of $32.61.
=IF(NOT(ISBLANK(Start_Date)),Total_Budget/(End_Date-Start_Date),"")
In a separate sheet, I have Budget and Spend fields for each month. For May, I need it to calculate the total budget for 5/1-5/15 of Campaign A, and 5/15-5/31 of Campaign B.
I got this far (J is the Daily_Budget, G is the Start_Date, and H is the End_Date):
=SUMIFS(Google!J2:J30, Google!G2:G30,"<="&DATE(2020,5,1),Google!H2:H30,">="&DATE(2020,5,31))
Then I was at a loss for how to extrapolate the number of days from the range, so that I could then multiply them by the Daily Budget and then add them together.
I thought of going back to the sheet that contains the campaigns and adding columns for each month with a complicated conditional, and then just using SUM(), but I feel like there has to be a more elegant solution.
UPDATE
Per request, here is a link to the spreadsheet with the desired results manually entered: Click here. May & June show the campaign partial month overlaps. The result I'm ultimately going for is =(15*Google!J2)+(16*Google!J3).
UPDATE 2 (24Jun20)
Per request, I have shared the spreadsheet so that people can make a copy and experiment with formulas: Click here..
Any ideas?
Thanks,
Ty
I would use the function DATEDIF() (documentation here). You can set the first parameter as the first day of the month you are trying to calculate the number of days within it, and the second as the first day from another month. Example:
DATEDIF(DATE(2020, 1, 1), DATE(2020, 2, 1), "D")
You could probably make a custom function with this as well to input only the number of each month (and year, in case of leap years on February), but I don't have much experience with that unfortunately.

Average of cell content based on day of month

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)

How to Count Timestamp on Google Spreadsheets?

My responses are timestamped as soon as anyone submits a survey. I wanted to count those timestamp monthwise.
URL - https://docs.google.com/spreadsheet/ccc?key=0AkpZp6MVqYv1dE5SZjJIODB1WF9nZDR6b1ZJZjFPenc&usp=sharing
I wanted to find out number of positive responses for a particular question (lets say Q1) for a particular month (lets say May)
Column G is not founded out based on the timestamp of Q1, I had asked the user the month, but that's not the correct way to do so, so I have stopped asking the user to enter the month.
First you have to overcome the fact that the timestamp isn't compatible with googles date format. No biggie,... luckily it looks like you have a fixed format ie DD/MM/YYYY. So you can use the LEFT and RIGHT formulas like so =right(left(a2,5),2) This will give you the month in text, ie 05.
Great.
Now for the harder stuff. If you have the newer google spreadsheets, you can simply use countifs to the effect of:
=countifs(arrayformula(right(left(A$2:A,5),2)),"=05",B$2:B,"=Positive")
For each month, replace the "=05" with the the date number you want. You could also make a month lookup chart for all months and questions so that you don't have to modify the formula for each month and quesiton. For this you replace the "=05" with =[cell number containing month number as text] (NOTE: for making a lookup key, you will have to pay close attention to the fact that you are getting TEXT in the formula above vice a number. There is a difference and they are not compatible as-is.)
Let's say you don't have the new google spreadsheets. Then you can use the old sumproduct() and if(). Yes, it is old. See the following:
=sumproduct(arrayformula(if(right(left(A$2:A,5),2)="05",1,0)),arrayformula(if(B$2:B="Positive",1,0)))
Note in both of these, you need to use arrayformula to convert the column with the timestamp into something useable. If you want to make this part easier by removing the parseing functions (LEFT() and RIGHT()) you need to change the timestamp format to be MM/DD/YYYY. Then you can plug in the the MONTH(DATE) formula and it will be done.
Then make a master sheet like so (note my formula has a "'" in it to make it visible for purposes of demonstration, you should remove it.):
Careful inspection might note that the count is wrong. That is because when I imported your timestamps, times like "02/06/2014 ..." were interpreted to mean "February 06" because of google's auto-formatting. In your sheet you will get the correct count using this formula, because of the way your timestamp is auto-populated.
HINT: To make the month a text you need to enter ="05" in the Month column
Please let me know how you make out.

Resources