Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I would like to calculate our margin year over year. I had a formula that worked for the current year.
Last year margin =
Solved! Go to Solution.
Hi @Anonymous ,
You want to use the slicer to select the year to return the value of the previous year of the selected year, right? Then you need a separate year table, which has nothing to do with the main table.
Here's my example.
Sample data:
1.Create a measure.
PreviousYear Value = CALCULATE(SUM('Table'[Value]),FILTER('Table',[Year]=SELECTEDVALUE('Table (2)'[Year])-1))
2.Create a slicer with the year field from Table(2). In the table visual, the year field is from Table. When I selcet year 2020, it shows the value in 2019.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
You may be slightly overcomplicating this
LastYearMargin = CALCULATE([CurrentYearMargin],SAMEPERIODLASTYEAR(Table[Date]))
(although this will work more reliably if you have a true calendar table)
@lbendlinthanks for your response!
I can definitely try that. But will that also work with a slicer like this?
Because if I use the measure [CurrentYear] it will always return 2021 right? Even if the slicer 2020 is selected.
Hi @Anonymous ,
You want to use the slicer to select the year to return the value of the previous year of the selected year, right? Then you need a separate year table, which has nothing to do with the main table.
Here's my example.
Sample data:
1.Create a measure.
PreviousYear Value = CALCULATE(SUM('Table'[Value]),FILTER('Table',[Year]=SELECTEDVALUE('Table (2)'[Year])-1))
2.Create a slicer with the year field from Table(2). In the table visual, the year field is from Table. When I selcet year 2020, it shows the value in 2019.
Best Regards,
Stephen Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
No. [CurrentYear] has nothing to do with 2021. It is based on the current filter context for each element of your visual.
You might consider renaming the measure to reduce the ambiguity.
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
19 | |
7 | |
6 | |
5 | |
5 |
User | Count |
---|---|
25 | |
10 | |
10 | |
9 | |
6 |