Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

Creating measure filtered to one less than the value of a slicer

Hi All,

 

I am currently struggling with an issue whereby I am comparing years of data against each other. My table looks similar to the one below:

 

YearValue
2018

14706.92

201913193.76
202010926.98

 

I also have a year slicer, to select which year I am viewing as my "Current Year". I want to create a new measure, which will be my "Previous Year Value", which is filtered to the year before the selected "Current Year". I then want to be able to calculate the difference between the current year and the previous year values.

 

It would look something like this:

2019-11-15_11-18-37.jpg

 

 

 

 

 

 

 

Please note if 2020 was selected, all of these values would dynamically update.

If anyone has a smart solution please let me know.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, I actually managed to get a solution myself using a date dimension table.

 

This table was calculated with: 

Date Dim = CALENDAR(MIN('Sales Table'[Date]), MAX('Sales Table'[Date]))
 
I then had my current year as a simple sum, and then my previous year value was calculated with the dax:
 
Volume Selected Yr-1 =
VAR LAGDATE = YEAR(MAX('Date Dim'[Date]))-1
RETURN
CALCULATE([Value], ALL('Date Dim'), ALL(Sheet1[Date]), YEAR(Sheet1[Date]) = LAGDATE)

 

This got me the solution, thanks for everyones help anyway!

View solution in original post

6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

The first Table you have shared in your initial post looks like a visual that you have created (Table or matrix) not your actual input table.  Share your actual input table.  Does the actual input table have a proper Date column?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Hi, I actually managed to get a solution myself using a date dimension table.

 

This table was calculated with: 

Date Dim = CALENDAR(MIN('Sales Table'[Date]), MAX('Sales Table'[Date]))
 
I then had my current year as a simple sum, and then my previous year value was calculated with the dax:
 
Volume Selected Yr-1 =
VAR LAGDATE = YEAR(MAX('Date Dim'[Date]))-1
RETURN
CALCULATE([Value], ALL('Date Dim'), ALL(Sheet1[Date]), YEAR(Sheet1[Date]) = LAGDATE)

 

This got me the solution, thanks for everyones help anyway!

v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

We can try to create following three measures to meet your requirement:

 

Current Year Value = 
CALCULATE ( SUM ( 'Table'[Value] ) )

 

Previous Year Value = 
CALCULATE (
    SUM ( 'Table'[Value] ),
    FILTER ( ALL ( 'Table' ), [Year] = SELECTEDVALUE ( 'Table'[Year] ) - 1 )
)

 

Delta = [Current Year Value] - [Previous Year Value]

 

5.PNG6.PNG


BTW, pbix as attached.

 

Best regards,

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hello @Anonymous !

 

Have you tried Year to Date formula? 

Anonymous
Not applicable

Hi @Anonymous , could you please expand on this? Not sure how this can solve my problem

Anonymous
Not applicable

How do you have your data organized? Is been your total value calculated by a DAX formula? 

 

btw, this is what I refer to: https://docs.microsoft.com/es-es/dax/totalytd-function-dax

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors