Bird
Raised Fist0
Tableaubi_tool~15 mins

Relative date filtering in Tableau - Real Business Scenario

Choose your learning style10 modes available

Start learning this pattern below

Jump into concepts and practice - no test required

or
Recommended
Test this pattern10 questions across easy, medium, and hard to know if this pattern is strong
Scenario Mode
👤 Your Role: You are a sales analyst at a retail company.
📋 Request: Your manager wants to see the sales performance for the last 3 months compared to the same period last year. They want a dashboard that automatically updates to always show the most recent 3 months of data.
📊 Data: You have a sales dataset with columns: Order Date, Sales Amount, Region, and Product Category. The data covers multiple years.
🎯 Deliverable: Create a Tableau dashboard with a line chart showing monthly sales for the last 3 months and the same 3 months last year, using relative date filtering to keep the data current.
Progress0 / 8 steps
Sample Data
Order DateSales AmountRegionProduct Category
2023-03-151200EastElectronics
2023-04-101500WestFurniture
2023-05-051700EastElectronics
2022-03-201100EastElectronics
2022-04-151400WestFurniture
2022-05-101600EastElectronics
2023-01-25900SouthOffice Supplies
2023-02-141000NorthFurniture
2022-01-30850SouthOffice Supplies
2022-02-18950NorthFurniture
1
Step 1: Connect your sales data to Tableau and open a new worksheet.
No formula needed.
Expected Result
Data is loaded and ready for analysis.
2
Step 2: Create a calculated field to extract the month and year from Order Date for grouping.
Create calculated field named 'Month Year' with formula: DATETRUNC('month', [Order Date])
Expected Result
A new field 'Month Year' that groups dates by month and year.
3
Step 3: Drag 'Month Year' to Columns and 'SUM(Sales Amount)' to Rows to create a line chart of monthly sales.
No formula needed.
Expected Result
Line chart showing total sales per month.
4
Step 4: Add a relative date filter on 'Order Date' to show only the last 3 months.
Right-click 'Order Date' > Filter > Relative Date > Select 'Months' and 'Last 3 months'.
Expected Result
Chart updates to show sales data only for the last 3 months.
5
Step 5: Duplicate the worksheet to create a comparison for the same 3 months last year.
No formula needed.
Expected Result
Second worksheet ready for last year data.
6
Step 6: On the duplicated worksheet, edit the relative date filter to show the same 3 months but for last year.
Right-click 'Order Date' > Filter > Relative Date > Select 'Months' and 'Last 3 months' > Check 'Previous Year'.
Expected Result
Chart shows sales data for the same 3 months last year.
7
Step 7: Create a dashboard and add both worksheets side by side with clear titles: 'Last 3 Months Sales' and 'Same Period Last Year'.
No formula needed.
Expected Result
Dashboard displays two line charts for easy comparison.
8
Step 8: Test the dashboard by changing the system date or refreshing data to confirm the relative date filters update automatically.
No formula needed.
Expected Result
Dashboard always shows the most recent 3 months and the same period last year without manual changes.
Final Result
Dashboard: Relative Date Sales Comparison

+-------------------------+  +------------------------------+
| Last 3 Months Sales      |  | Same Period Last Year Sales   |
|                         |  |                              |
|  *---*---*---*---*---*  |  |  *---*---*---*---*---*---*   |
|  |   |   |   |   |   |  |  |  |   |   |   |   |   |   |   |
|  |   |   |   |   |   |  |  |  |   |   |   |   |   |   |   |
|  *---*---*---*---*---*  |  |  *---*---*---*---*---*---*   |
|  Mar  Apr  May           |  |  Mar  Apr  May                |
+-------------------------+  +------------------------------+
Sales in the last 3 months show an increasing trend.
Compared to the same period last year, sales have grown by approximately 10%.
The relative date filter keeps the dashboard updated automatically.
Bonus Challenge

Add a filter to the dashboard that allows the manager to select different time ranges like last 6 months or last year dynamically.

Show Hint
Use Tableau's relative date filter with 'Range of dates' option and add it as a dashboard filter control.

Practice

(1/5)
1. What does a Relative Date filter in Tableau do?
easy
A. It filters data based on fixed dates you manually select.
B. It shows data for a dynamic time period like last 7 days or this month.
C. It groups data by categories like product or region.
D. It sorts data alphabetically by date.

Solution

  1. Step 1: Understand the purpose of Relative Date filter

    A Relative Date filter dynamically adjusts the data shown based on the current date, such as last 7 days or this month.
  2. Step 2: Compare with other filter types

    Fixed date filters require manual date selection, unlike Relative Date filters which update automatically.
  3. Final Answer:

    It shows data for a dynamic time period like last 7 days or this month. -> Option B
  4. Quick Check:

    Relative Date filter = dynamic time period [OK]
Hint: Relative Date filters always adjust with today's date [OK]
Common Mistakes:
  • Confusing Relative Date with fixed date filters
  • Thinking it sorts data instead of filtering
  • Assuming it groups data by categories
2. Which of the following is the correct way to apply a Relative Date filter in Tableau?
easy
A. Drag a date field to Filters, choose 'Relative Date', then select the desired period.
B. Drag a measure to Filters and select 'Relative Date'.
C. Right-click a dimension and select 'Sort by Relative Date'.
D. Create a calculated field with TODAY() and filter manually.

Solution

  1. Step 1: Identify how to apply Relative Date filter

    In Tableau, you drag a date field to the Filters shelf and then choose 'Relative Date' to set dynamic periods.
  2. Step 2: Eliminate incorrect options

    Measures cannot be filtered by Relative Date, sorting is different, and manual calculated fields are not the standard method.
  3. Final Answer:

    Drag a date field to Filters, choose 'Relative Date', then select the desired period. -> Option A
  4. Quick Check:

    Apply Relative Date filter via date field in Filters [OK]
Hint: Always start with a date field for Relative Date filters [OK]
Common Mistakes:
  • Trying to apply Relative Date on measures
  • Confusing sorting with filtering
  • Using manual calculated fields unnecessarily
3. Given today's date is 2024-06-15, what data will be shown if you apply a Relative Date filter for 'Last 7 days' on a sales date field?
medium
A. Sales data from 2024-06-01 to 2024-06-07 inclusive.
B. Sales data from 2024-06-15 only.
C. Sales data from 2024-06-08 to 2024-06-14 inclusive.
D. Sales data from 2024-06-09 to 2024-06-15 inclusive.

Solution

  1. Step 1: Understand 'Last 7 days' relative to today

    'Last 7 days' means the past 7 days including today.
  2. Step 2: Calculate the date range

    From 2024-06-15, last 7 days are 2024-06-09 through 2024-06-15 inclusive.
  3. Final Answer:

    Sales data from 2024-06-09 to 2024-06-15 inclusive. -> Option D
  4. Quick Check:

    Last 7 days includes today, from today back 6 days [OK]
Hint: Last 7 days includes today, 7 days ending today [OK]
Common Mistakes:
  • Excluding today's date mistakenly
  • Counting from beginning of month
  • Confusing with previous full week
4. You applied a Relative Date filter for 'This Month' but your dashboard shows no data. What is the most likely cause?
medium
A. The filter was set to 'Last Year' instead of 'This Month'.
B. You applied the filter on a non-date field.
C. The date field has no data for the current month.
D. The data source is disconnected.

Solution

  1. Step 1: Check data availability for current month

    If no data exists for the current month, the 'This Month' filter will show no results.
  2. Step 2: Consider other causes but focus on data

    Applying filter on non-date fields or wrong filter choice would cause errors or different results; disconnected data source usually causes errors, not empty data.
  3. Final Answer:

    The date field has no data for the current month. -> Option C
  4. Quick Check:

    No data in current month = empty 'This Month' filter result [OK]
Hint: Check if data exists for the filtered period first [OK]
Common Mistakes:
  • Assuming filter syntax error without checking data
  • Ignoring data source connection status
  • Confusing filter period with applied filter
5. You want to create a dashboard that always shows sales data for the last 30 days but excludes today. Which Relative Date filter setting should you use?
hard
A. Set filter to 'Last 30 days' excluding today.
B. Set filter to 'Last 31 days' including today.
C. Set filter to 'This Month' and manually exclude today.
D. Set filter to 'Last 30 days' including today.

Solution

  1. Step 1: Understand requirement to exclude today

    The filter must show the 30 days before today, not including today itself.
  2. Step 2: Choose correct Relative Date filter option

    'Last 30 days' excluding today matches the requirement exactly; including today or using 'This Month' won't exclude today properly.
  3. Final Answer:

    Set filter to 'Last 30 days' excluding today. -> Option A
  4. Quick Check:

    Exclude today by choosing 'Last 30 days' without today [OK]
Hint: Use 'Last 30 days' excluding today for past 30 full days [OK]
Common Mistakes:
  • Including today when it should be excluded
  • Using 'This Month' which varies in length
  • Adding extra days unnecessarily