Bird
Raised Fist0
Tableaubi_tool~20 mins

Date hierarchy (year, quarter, month, day) in Tableau - Practice Problems & Coding Challenges

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
Challenge - 5 Problems
🎖️
Date Hierarchy Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
dax_lod_result
intermediate
2:00remaining
Calculate Total Sales for the Current Quarter

You have a sales dataset with a date field. Using a date hierarchy (year, quarter, month, day), which DAX expression correctly calculates the total sales for the current quarter?

ACALCULATE(SUM(Sales[Amount]), FILTER(ALL('Date'), 'Date'[Quarter] = QUARTER(TODAY()) && 'Date'[Year] = YEAR(TODAY())))
BSUM(Sales[Amount]) WHERE 'Date'[Quarter] = QUARTER(TODAY())
CSUMX(FILTER(Sales, QUARTER(Sales[Date]) = QUARTER(TODAY())), Sales[Amount])
DCALCULATE(SUM(Sales[Amount]), 'Date'[Quarter] = QUARTER(TODAY()) && 'Date'[Year] = YEAR(TODAY()))
Attempts:
2 left
💡 Hint

Remember to use CALCULATE with FILTER and ALL to remove filters on the date table.

visualization
intermediate
1:30remaining
Best Visualization for Showing Sales Trend by Date Hierarchy

You want to show sales trends over time using a date hierarchy (year, quarter, month, day). Which Tableau visualization type is best suited for this purpose?

APie chart showing sales by year
BLine chart with date hierarchy on the x-axis
CBar chart with sales by product category
DScatter plot with sales amount vs. product price
Attempts:
2 left
💡 Hint

Think about how to show changes over time clearly.

data_modeling
advanced
2:30remaining
Designing a Date Dimension Table for Hierarchy

Which of the following is the best practice when designing a date dimension table to support a date hierarchy (year, quarter, month, day) in a BI model?

AUse a single integer column representing the date as YYYYMMDD without separate hierarchy columns
BStore only the full date as a string and parse it in visuals
CExclude the date dimension and use transaction dates directly in fact tables
DInclude separate columns for Year, Quarter, Month, and Day with proper data types and relationships
Attempts:
2 left
💡 Hint

Think about how hierarchies work in BI tools.

🎯 Scenario
advanced
2:30remaining
Troubleshooting Date Hierarchy Drill-Down Issue

A user reports that when drilling down from year to quarter in a Tableau dashboard, the quarters do not display correctly and some months are missing. What is the most likely cause?

AThe date hierarchy is set to use fiscal quarters instead of calendar quarters
BThe dashboard filter is set to exclude quarters
CThe date field is not recognized as a date data type in Tableau
DThe sales data has missing values for some months
Attempts:
2 left
💡 Hint

Check the data type of the date field in Tableau.

🔧 Formula Fix
expert
3:00remaining
Identify the Error in Date Hierarchy Calculation

Given the following DAX measure to calculate sales for the current month in a date hierarchy, what error will occur?

CurrentMonthSales = CALCULATE(SUM(Sales[Amount]), FILTER(ALL('Date'), 'Date'[Month] = MONTH(TODAY())))
Tableau
CurrentMonthSales = CALCULATE(SUM(Sales[Amount]), FILTER(ALL('Date'), 'Date'[Month] = MONTH(TODAY())))
AThe measure will return sales for all years in the current month, not just the current year
BSyntax error due to missing YEAR filter
CType error because MONTH() cannot be used in FILTER
DThe measure will return zero because ALL('Date') removes all filters
Attempts:
2 left
💡 Hint

Consider what happens when filtering only by month number without year.

Practice

(1/5)
1. What is the main purpose of a Date hierarchy in Tableau?
easy
A. To explore data by Year, Quarter, Month, and Day levels easily
B. To create new calculated fields based on dates
C. To filter data only by year
D. To sort data alphabetically

Solution

  1. Step 1: Understand what a date hierarchy does

    A date hierarchy organizes dates into levels like Year, Quarter, Month, and Day for easy exploration.
  2. Step 2: Compare options to this purpose

    Only To explore data by Year, Quarter, Month, and Day levels easily describes exploring data by these date levels. Others describe unrelated tasks.
  3. Final Answer:

    To explore data by Year, Quarter, Month, and Day levels easily -> Option A
  4. Quick Check:

    Date hierarchy = Explore by date levels [OK]
Hint: Date hierarchy breaks dates into levels for easy drill-down [OK]
Common Mistakes:
  • Thinking it only filters by year
  • Confusing with calculated fields
  • Assuming it sorts alphabetically
2. Which of the following is the correct way to create a date hierarchy in Tableau?
easy
A. Write a SQL query to group dates by year
B. Drag a date field to Rows, then right-click and select 'Create Hierarchy', adding Year, Quarter, Month, Day
C. Use the filter pane to select Year, Quarter, Month, and Day separately
D. Manually type dates in a new column

Solution

  1. Step 1: Recall Tableau's method to create hierarchies

    In Tableau, you create hierarchies by dragging fields and grouping them, not by SQL or typing dates manually.
  2. Step 2: Identify the correct process

    Drag a date field to Rows, then right-click and select 'Create Hierarchy', adding Year, Quarter, Month, Day correctly describes dragging a date field and creating a hierarchy with Year, Quarter, Month, and Day.
  3. Final Answer:

    Drag a date field to Rows, then right-click and select 'Create Hierarchy', adding Year, Quarter, Month, Day -> Option B
  4. Quick Check:

    Create hierarchy by drag and right-click [OK]
Hint: Right-click date field to create hierarchy in Tableau [OK]
Common Mistakes:
  • Trying to create hierarchy via SQL
  • Using filters instead of hierarchy
  • Typing dates manually instead of using fields
3. Given a date hierarchy with Year > Quarter > Month > Day, what happens when you double-click the Year field in Tableau's view?
medium
A. Tableau filters data to the current Year only
B. Tableau drills down to show data by Day directly
C. Tableau shows data aggregated by Year only
D. Tableau shows data aggregated by Month only

Solution

  1. Step 1: Understand double-click on a hierarchy level

    Double-clicking a level like Year shows data aggregated at that level, not deeper levels.
  2. Step 2: Match behavior to options

    Tableau shows data aggregated by Year only correctly states data is aggregated by Year only. Other options describe filtering or drilling down incorrectly.
  3. Final Answer:

    Tableau shows data aggregated by Year only -> Option C
  4. Quick Check:

    Double-click Year = aggregate by Year [OK]
Hint: Double-click a level to see data summarized at that level [OK]
Common Mistakes:
  • Thinking double-click drills down multiple levels
  • Confusing aggregation with filtering
  • Assuming it shows data by Month or Day immediately
4. You created a date hierarchy but when you try to drill down from Year to Quarter, Tableau shows no data. What is the most likely cause?
medium
A. The Year field is not a date type
B. The data source has no date values
C. You forgot to refresh the data source
D. The Quarter field is not included in the hierarchy

Solution

  1. Step 1: Analyze why drill down shows no data

    If drilling from Year to Quarter shows no data, likely the Quarter level is missing in the hierarchy.
  2. Step 2: Evaluate other options

    Data source missing dates or Year not date type would cause bigger issues; refreshing data is less likely the cause.
  3. Final Answer:

    The Quarter field is not included in the hierarchy -> Option D
  4. Quick Check:

    Missing Quarter in hierarchy blocks drill down [OK]
Hint: Check all date levels are in the hierarchy to drill down [OK]
Common Mistakes:
  • Assuming data source is empty without checking
  • Forgetting to include all date parts in hierarchy
  • Thinking refresh fixes hierarchy structure
5. You want to create a dashboard showing sales trends by Year, then allow users to drill down to Quarter, Month, and Day. Which approach best uses Tableau's date hierarchy feature?
hard
A. Create a date hierarchy with Year > Quarter > Month > Day and use it in the view with drill-down enabled
B. Create separate sheets for Year, Quarter, Month, and Day and link them with filters
C. Use only the Month field and filter manually for Year and Quarter
D. Create calculated fields for each date part and display them side by side

Solution

  1. Step 1: Identify best practice for drill-down in Tableau

    Using a date hierarchy with levels Year > Quarter > Month > Day allows smooth drill-down in one view.
  2. Step 2: Compare other options

    Separate sheets or manual filters are more complex and less user-friendly; calculated fields side by side don't enable drill-down.
  3. Final Answer:

    Create a date hierarchy with Year > Quarter > Month > Day and use it in the view with drill-down enabled -> Option A
  4. Quick Check:

    Date hierarchy enables smooth drill-down [OK]
Hint: Use one hierarchy for drill-down, not separate sheets [OK]
Common Mistakes:
  • Creating multiple sheets instead of one hierarchy
  • Using only one date part without hierarchy
  • Relying on calculated fields instead of hierarchy