0
0
Tableaubi_tool~10 mins

Date filters in Tableau - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to filter data for the year 2023.

Tableau
IF YEAR([Order Date]) = [1] THEN 'Include' ELSE 'Exclude' END
Drag options to blanks, or click blank then click option'
A2023
B2022
C2024
D2021
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong year value.
Not using the YEAR function to extract the year.
2fill in blank
medium

Complete the code to filter data for dates after January 1, 2023.

Tableau
IF [Order Date] > DATE('[1]') THEN 'Include' ELSE 'Exclude' END
Drag options to blanks, or click blank then click option'
A2022-01-01
B2022-12-31
C2023-01-02
D2023-01-01
Attempts:
3 left
💡 Hint
Common Mistakes
Using a date before January 1, 2023.
Using the wrong date format.
3fill in blank
hard

Fix the error in the code to filter data for the current month.

Tableau
IF DATETRUNC('month', [Order Date]) = DATETRUNC('month', [1]) THEN 'Include' ELSE 'Exclude' END
Drag options to blanks, or click blank then click option'
ATODAY()
BNOW()
CDATE()
DGETDATE()
Attempts:
3 left
💡 Hint
Common Mistakes
Using NOW() which includes time and may cause mismatch.
Using undefined functions like GETDATE() in Tableau.
4fill in blank
hard

Fill both blanks to filter data between January 1, 2023 and December 31, 2023.

Tableau
IF [Order Date] >= DATE('[1]') AND [Order Date] <= DATE('[2]') THEN 'Include' ELSE 'Exclude' END
Drag options to blanks, or click blank then click option'
A2023-01-01
B2023-12-31
C2022-12-31
D2024-01-01
Attempts:
3 left
💡 Hint
Common Mistakes
Using dates outside the 2023 year range.
Swapping start and end dates.
5fill in blank
hard

Fill all three blanks to filter data for the last 7 days including today.

Tableau
IF [Order Date] >= DATEADD('day', -[1], [2]) AND [Order Date] <= [3] THEN 'Include' ELSE 'Exclude' END
Drag options to blanks, or click blank then click option'
A7
BTODAY()
D30
Attempts:
3 left
💡 Hint
Common Mistakes
Using 30 days instead of 7.
Using NOW() instead of TODAY() causing time issues.