Q:

Last 7 days data calculation in Tableau

I am having an issue in calculating last week data in Tableau. Below is my scenario:
In my dashboard, I have a slider which selects the date. In my table, I have a list of users where I will be showing each of them's call records. One column will have last week records and one will have total records.
For Total records, there is not an issue. But for finding last week's count, I need to have a calculated field, that needs to subtract 7 days from the date selected and then give out the number of records for each user.
Say I have selected date as 25-04-2017, then my table should show all the records until 25-04-2017 in one column and other should show data from 18-04-2017 till 25-04-2017.

A:

You can filter it with Relative days. When adding your dimension (date type) to the Filters list the picture below will appear. 

Now you can click on the relative date and to choose the best option for you. You can see it in the picture below.

A:

I was able to find the solution for my issue. 
I created a boolean field as Max7Days with the formula as below:
DATEDIFF('day', [Date] , {MAX([Date])} ) <= 7

And created another that would count the number of records for the last 7 days if the condition was true as per the below formula:
CASE [Max7Days]
WHEN TRUE
THEN
[Number of Records]
END

