This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreLevel up your Power BI skills this month - build one visual each week and tell better stories with data! Get started
I'm been handed a dashboard which is currently not providing an accurate output and I'm trying to determine where the errors in the DAX are.
The report has a slicer where the user selects a date range and budget, actual, and % vs budget data is supposed to be shown for the current period (Range), QTD, & YTD.
I believe I've identified an issue with the DAX below.
The Prev Range Spend measure uses variables for Prev_Year_Start and Prev_Year_End. It appears the DAX for Selected_Prev_Year_Start will provide the MIN of the dates in my DIM_CALENDAR[Prev_Year_Start] column. This will be the January 1st of the previous year. Similarly it appears the DAX for Selected_Prev_Year_End will provide the MIN of dates in my DIM_CALENDAR[Prev_Year_End]. This will be December 31st of the previous year.
Instead what I want is the DAX for Selected_Prev_Year_Start and Selected_Prev_Year_End to provide the same dates selected in the slicer but for one year prior.
How can I Selected_Prev_Year_Start and Selected_Prev_Year_End so that they provide the same dates in the slicer but for one year prior?
Prev Range Spend =
VAR SelectedDate = SELECTEDVALUE('DIM_CALENDAR'[DATE])
VAR Prev_year_Start =
[Selected_Prev_Year_Start]
VAR Prev_year_End =
[Selected_Prev_Year_End]
RETURN
CALCULATE(
SUM(FACT_SPEND[SPEND]),
'DIM_CALENDAR'[DATE] >= Prev_year_Start &&
'DIM_CALENDAR'[DATE] <= Prev_year_End
)
Selected_Prev_Year_Start =
CALCULATE(
MIN('DIM_CALENDAR'[Prev_Year_Start]),
ALLSELECTED('DIM_CALENDAR')
)
Selected_Prev_Year_End =
CALCULATE(
MIN('DIM_CALENDAR'[Prev_Year_End]),
ALLSELECTED('DIM_CALENDAR')
)
Solved! Go to Solution.
Hi @ERing
You can use EDATE to get the date months back. For example
EDATE ( [Selected_Prev_Year_Start], -12 )
Or you can use SAMEPERIODLASTYEAR
CALCULATE (
[your measure],
SAMEPERIODLASTYEAR ( Dates[Date] ),
REMOVEFILTERS ( Dates )
)
REMOVEFILTERS is necessary is the Dates table hasn't been marked as a dates table.
Hi @ERing,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hi @ERing
You can use EDATE to get the date months back. For example
EDATE ( [Selected_Prev_Year_Start], -12 )
Or you can use SAMEPERIODLASTYEAR
CALCULATE (
[your measure],
SAMEPERIODLASTYEAR ( Dates[Date] ),
REMOVEFILTERS ( Dates )
)
REMOVEFILTERS is necessary is the Dates table hasn't been marked as a dates table.
@danextian
I don't believe this solves my problem. I need a way to create Selected_Prev_Year_Start so that its the slicer selection minus one year and a way to create Selected_Prev_Year_End so that its the slicer selection minus one year.
Hi @ERing,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.
Hi @ERing,
Thank you for reaching out to the Microsoft Fabric Forum community.
I understand your challenge—you need the prior-year dates (Selected_Prev_Year_Start and Selected_Prev_Year_End) to dynamically match the slicer’s selected range but shifted back by one year (e.g., March 10–16, 2025 → March 10–16, 2024). Here’s how to fix it:
If this post helps, then please give us ‘Kudos’ and consider Accept it as a solution to help the other members find it more quickly.
Thank you.
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 31 | |
| 25 | |
| 21 | |
| 18 | |
| 17 |
| User | Count |
|---|---|
| 61 | |
| 35 | |
| 33 | |
| 23 | |
| 23 |