In Tableau I have a db containing records with a create date [create date] I need to compare the number of records that came in last 7 days to the number of records that came in the last 7 days -1 . And show the change as a percentage.
Thanks
Assuming today is August 31th, last 7 days should be Aug 24-30, excluding today.
sum(if DATEDIFF('day',[Order Date],DATE(TODAY()-1)) <= 6 then 1 end )
If "7 days -1" means last 7 days starting from one day prior to yesterday, this second range is Aug 23-29.
sum(if DATEDIFF('day',[Order Date],DATE(TODAY()-2)) <= 6 then 1 end )
According to your different needs, you can just use this formula [(A/B)-1] in order to get the change in %:
(
sum(if DATEDIFF('day',[Order Date],DATE(TODAY()-1)) <= 6 then 1 end )
/
sum(if DATEDIFF('day',[Order Date],DATE(TODAY()-2)) <= 6 then 1 end )
)
-1