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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
PowerBI_Explore
New Member

Get previous value of a table and show as card

Hi there

I've got a table with 3 columns "Company", "Month" and "Rating":

PowerBI_Explore_0-1646084477558.png

Now I'd like to get a new column (or measure) to get the "Rating" of the previous available month.
If there isn't a value for an earlier month respectively it's the first entry (like Company A / Month 1), the value 0 should be displayed.

 

My final goal is to have two slicers, one for "Company" and one for "Month" and two card visuals with the information about the "current" rating and the previous rating:

PowerBI_Explore_1-1646084494337.png

How can I solve this by using DAX?

Thank you in advance for your help!

 

Best regards,

Tom

1 ACCEPTED SOLUTION
jaipal
Resolver III
Resolver III

@PowerBI_Explore Create a Index Column starts with 1

and create column with this DAX:

Previous Rating =
CALCULATE(MAX('Table'[Rating]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1))
 
Here is your expected result:
 
jaipal_0-1646098714775.png

 

 

View solution in original post

2 REPLIES 2
jaipal
Resolver III
Resolver III

@PowerBI_Explore Create a Index Column starts with 1

and create column with this DAX:

Previous Rating =
CALCULATE(MAX('Table'[Rating]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1))
 
Here is your expected result:
 
jaipal_0-1646098714775.png

 

 

Works perfectly like expected, appreciate your help - thank you very much!

 

Only need to figure out, how I should handle the first entry / record of every company correctly, so that it will display no value instead of the last value of the previous company. I think I should be able to solve this with the same logic and an additional check, if the company is the same then the one with index-1.

 

Best regards

Dominique

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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