Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
Solved! Go to Solution.
Hi @afaro
Why not try the following few measures if you have a calander table in your data model,.
Base Sales Measure
Sales = SUM(Sales[Total])
YTD Sales
Sales - YTD = TOTALYTD([Sales], Calendar[Date])
PY Sales
Sales - PY =
CALCULATE([Sales - YTD], DATEADD(Calendar[Date], -1, YEAR))
Joe
If you found my answer helpful and it solved your issue, please accept as solution
Proud to be a Super User! | |
Date tables help! Learn more
Hi, @afaro
The problem with the first formula is the use of functions. Retains filters for all columns except the specified columns. In this case, you keep the filter, but remove all other columns (including .which is why your formula isn't filtered by the previous year as expected.) Instead, it calculates the total sales for all years, but doesn't filter by month as you might expect.
The correct logic you're looking for is to calculate the total sales for the same month but the previous year relative to the year selected in the slicer. Your second formula is more in line with this goal
However, to understand why the first formula doesn't work as intended, it's crucial to grasp how things work in a function. In your scenario, you want to keep the month filter, but move to the previous year, which isn't effectively communicated in the first formula.
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @afaro
The problem with the first formula is the use of functions. Retains filters for all columns except the specified columns. In this case, you keep the filter, but remove all other columns (including .which is why your formula isn't filtered by the previous year as expected.) Instead, it calculates the total sales for all years, but doesn't filter by month as you might expect.
The correct logic you're looking for is to calculate the total sales for the same month but the previous year relative to the year selected in the slicer. Your second formula is more in line with this goal
However, to understand why the first formula doesn't work as intended, it's crucial to grasp how things work in a function. In your scenario, you want to keep the month filter, but move to the previous year, which isn't effectively communicated in the first formula.
How to Get Your Question Answered Quickly
Best Regards
Yongkang Hua
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @afaro
Why not try the following few measures if you have a calander table in your data model,.
Base Sales Measure
Sales = SUM(Sales[Total])
YTD Sales
Sales - YTD = TOTALYTD([Sales], Calendar[Date])
PY Sales
Sales - PY =
CALCULATE([Sales - YTD], DATEADD(Calendar[Date], -1, YEAR))
Joe
If you found my answer helpful and it solved your issue, please accept as solution
Proud to be a Super User! | |
Date tables help! Learn more
Have you considered using SAMEPERIODLASTYEAR instead?
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 19 | |
| 10 | |
| 9 | |
| 4 | |
| 4 |
| User | Count |
|---|---|
| 31 | |
| 29 | |
| 21 | |
| 12 | |
| 12 |