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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Lakeside
New Member

Calculating last years value in a table

Hi, 

 

I have a quite seemingly simple problem that I can't get my head around. I have data that has three columns: A year column, a dimension column where each dimension repeats every year, and a value column of a decimal number. 

I would like to visualize this data ina  table and make a measure that returns last years value based on the year column. 

 

How do I do this?

 

Thanks!

Lakeside_0-1718869744742.png

 

1 ACCEPTED SOLUTION
AilleryO
Memorable Member
Memorable Member

Hi,

 

If your data are the same as the sample data you provided, this DAX should work :

Last Year Value =
VAR CurrentDim = SELECTEDVALUE( TableTEST[Dimension] )//Get current value for Dimension
VAR CurrentYear = SELECTEDVALUE( TableTEST[Year] )  //Get current value for Year
RETURN
CALCULATE( SUM( TableTEST[Value] ) ,
                    TableTEST[Year] = CurrentYear-1 , //To get last year
                    TableTEST[Dimension] = CurrentDim ) //On that dimension
To get this :
ValueLastYear.png
Let us know if this fits your requirements

View solution in original post

2 REPLIES 2
AilleryO
Memorable Member
Memorable Member

Hi,

 

If your data are the same as the sample data you provided, this DAX should work :

Last Year Value =
VAR CurrentDim = SELECTEDVALUE( TableTEST[Dimension] )//Get current value for Dimension
VAR CurrentYear = SELECTEDVALUE( TableTEST[Year] )  //Get current value for Year
RETURN
CALCULATE( SUM( TableTEST[Value] ) ,
                    TableTEST[Year] = CurrentYear-1 , //To get last year
                    TableTEST[Dimension] = CurrentDim ) //On that dimension
To get this :
ValueLastYear.png
Let us know if this fits your requirements
Lakeside
New Member

YearDimensionValueLast years value
2024A1,5 
2024B2 
2024C3 
2024D2,5 
2024E1 
2023A0,5 
2023B0,8 
2023C0,3 
2023D1 
2023E0,5 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.