Tableau_sales calculation 7 days ago - tableau-api

Could you help me with one question re Sales: now I have the amount of Sales by months, but I also would like to add column to see the amount 7 days ago to compare progress and difference. How could I do it?
enter image description here

Related

What is the correct order for substracting from a date

I just stumbled on an interesting problem when trying to calculate birthday from age. Basically the idea is to substract a number of years, months and days from the current date. However depending on the order of subtraction eg smaller to larger units or vice versa the result is different.
For example we need to substract 55 years 3 months and 14 days from 2021-01-13
If I subtract the years first the result will be 1965-09-29
If I subtract the days first the result will be 1965-09-30
It all comes from the difference between the number of days in a month. Now I'm wondering which is the generally accepted order.

Dates, Days, Weeks, Difference, Training&shift start formula

Data shared in Google sheet found here:
I am trying to solve a quick issue to calculate the number of training days and working shifts days spent in a small range of calendar week based on a given 'training start date' and the below criteria:
Weeks are Sunday through Saturday
Each new agency staff should complete 4 days of training before being planned to work for a max of 6 days in and one calendar week
When less than 4 training days are completed during the first calendar week, the remaining roll over to the following, immediately followed by working days but not exceeding 6 days of work or training
To exclude Christmas day
Calculated from the given date for "Training start' calculate how many training shifts and working shifts for a period of calendar weeks
Calendar Weeks based on start/finish dates in the "dates' tab
Any advice, feedback or assistance in any way is greatly appreciated.

Checking days which are closest

This is going to be a bit hard to explain but
I have 2 dates, i'm interested in the day and month unless the 2 dates have the same year
2015/12/30 and 2019/01/04
ignoring the year part (kind of) the result i'm expecting 6 days difference for the 2 dates above
if i was to use date.DayOfYear i would get 364 (2015/12/30) and 4 (2019/01/04) respectively
however if the years are same then
2019/01/04 2019/12/30 then the result i'm expecting is 359 days difference
is there a clever way of doing this without peppering the code with if statements?
If the year difference was just 0 or 1, then you could just convert both dates to an absolute value (in seconds, ms, unix time or whatever), subtract the 2 values and convert it to full days. But if you have more than 1 year diff (as 2015 and 2019), then you have to have an "if" an think about what are you actually trying to do there. You shouldn't use DayOfYear, because some years have 366 days, so you can't be sure that 364 corresponds to 1 or 2 days left in that year.

Rolling Count of Values BETWEEN two dates, 12 to 24 months ago (SPOTFIRE Custom Expression)

I am struggling to create this calculation.
I need to create a rolling count of all of a columns values BETWEEN two dates. 12 to 24 months ago.
I do not want to do this by limiting data, I need it in the custom expression due to other work.
Currently I have this equation. I thought this would at least calculate all the values since two years ago but it fails to do that as well. Does anyone have a simpler way to calculate 12 to 24 months ago?
(((Count(If(((Month([DATE])>=Month(DateAdd("mm",-24,DateTimeNow())))
and (Year([DATE])>=Year(DateAdd("yy",-2,DateTimeNow())))),
[EXTRAPOLATEDPRESSURE],null)))))
Solved. I was making it to complex with the Month and Year aspects.
Count(If(([DATE]>=dateadd("mm",-24,DateTimeNow())) and ([DATE]<=dateadd("mm",-12,DateTimeNow())),
[EXTRAPOLATEDPRESSURE],null))

Calculate Percentage Overtime in SSRS 2012

I am trying create a report that calcualtes the Overtime someone has worked in a week, my understanding of the calulation would be.
My Columns are :
Extra Hours Worked Per Week
Total Hour Worked Per Week
Calculation
Extra Hours Worked Per Week / (Extra Hours Worked Per Week + Total Hour Worked Per Week) * 100
If I represent All the columns as minutes sum them up and do the calculation I get one figure but if I sum up all the minutes in to hours and minutes and do the same calculation I get a different figure. What I want to know is, is the Calculation correct and if so, should I be doing the calculation just using minutes or using hours and minutes.
Hope someone can help.
Assuming you want to calculate the percentage of Extra hours, your calculation should be:
((TotalHours * 100)/(TotalHours - ExtraHours))-100
And my advise to you is to keep the calculation in minutes, and in the end convert it to hours (and minutes).