0
0
Power BIbi_tool~20 mins

DATEADD for period shifts in Power BI - Practice Problems & Coding Challenges

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
DATEADD Mastery Badge
Get all challenges correct to earn this badge!
Test your skills under time pressure!
dax_lod_result
intermediate
2:00remaining
Calculate Sales for Previous Month Using DATEADD

You have a Sales table with a Date column and a SalesAmount column. You want to create a measure that calculates total sales for the previous month using the DATEADD function.

Which of the following DAX measures correctly calculates the previous month's sales?

APrevious Month Sales = CALCULATE(SUM(Sales[SalesAmount]), PREVIOUSMONTH(Sales[Date]))
BPrevious Month Sales = CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], 1, MONTH))
CPrevious Month Sales = CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -1, YEAR))
DPrevious Month Sales = CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -1, MONTH))
Attempts:
2 left
💡 Hint

Remember, DATEADD shifts the dates by the number of intervals you specify. Negative values move backward in time.

visualization
intermediate
2:00remaining
Visualizing Sales Shifted by Quarter Using DATEADD

You want to create a line chart showing total sales for the current quarter and the same quarter last year. You have a measure using DATEADD to shift the date by -4 quarters.

Which visual setup best helps compare these two periods clearly?

AUse a line chart with Date on the X-axis and two measures: Current Quarter Sales and Sales shifted by DATEADD with -4 quarters, with a legend for each measure.
BUse a stacked bar chart with Date on the X-axis and total sales only, no shifted measure.
CUse a pie chart showing sales for the current quarter only.
DUse a table visual listing sales by month without any time shift.
Attempts:
2 left
💡 Hint

To compare two time periods, a line chart with both measures helps see trends side by side.

data_modeling
advanced
2:00remaining
Handling Missing Dates in DATEADD Calculations

Your date table has missing dates for weekends. You use DATEADD to shift sales by one month. What problem can occur and how to fix it?

ADATEADD causes errors if dates are missing; fix by removing weekends from sales data.
BDATEADD will automatically fill missing dates; no fix needed.
CDATEADD may return blank results for missing dates; fix by ensuring the date table has continuous dates including weekends.
DDATEADD ignores missing dates and sums all sales regardless of date continuity.
Attempts:
2 left
💡 Hint

Think about how DATEADD works with continuous date ranges.

🎯 Scenario
advanced
2:00remaining
Using DATEADD to Compare Sales Year Over Year with Filters

You want to create a measure that calculates sales for the same period last year but only for a specific product category. Which DAX measure correctly applies the filter and uses DATEADD?

ASales LY Category = CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -1, YEAR), FILTER(Sales, Sales[Category] = "Electronics"))
BSales LY Category = CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -1, YEAR), Sales[Category] = "Electronics")
CSales LY Category = CALCULATE(SUM(Sales[SalesAmount]), DATEADD(Sales[Date], -1, YEAR)) + FILTER(Sales, Sales[Category] = "Electronics")
DSales LY Category = CALCULATE(SUM(Sales[SalesAmount]), FILTER(ALL(Sales), Sales[Category] = "Electronics"), DATEADD(Sales[Date], -1, YEAR))
Attempts:
2 left
💡 Hint

Filters inside CALCULATE can be table filters or filter expressions. Use FILTER for row context filters.

🔧 Formula Fix
expert
2:00remaining
Diagnosing Unexpected Results with DATEADD and Fiscal Year

You have a fiscal calendar starting in April. You use DATEADD to shift sales by -1 year, but the results do not align with fiscal years. What is the likely cause?

ADATEADD cannot shift by years; use MONTH instead.
BDATEADD uses the calendar year from the Date column, ignoring fiscal year settings; fix by creating a fiscal date table and using it in DATEADD.
CDATEADD automatically adjusts for fiscal years; no fix needed.
DThe sales data must be sorted by fiscal year for DATEADD to work correctly.
Attempts:
2 left
💡 Hint

Think about how DATEADD interprets the date column and fiscal calendars.