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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
hony
Frequent Visitor

How to calculate %-change to previous row with partition by (grouping)

Hi there,

 

I have to use DAX to do this:

 

For Each Group of Material (first column) I want to calculate the difference of the price compared to previous row. 

 

I tried to find a solution that is there but only found ways to do it without the partition of material (first column).

 

Thanks a lot

 

hony_0-1648642841628.png

 

1 REPLY 1
amitchandak
Super User
Super User

@hony , Try a new column like

 

New column =
var _max = maxx(filter(Table, [Material] = earlier([Material]) && [Date_eop] < earlier([Date_eop])), [Date_eop])
var _price =maxx(filter(Table, [Material] = earlier([Material]) && [Date_eop] < =_max), [price])
return
divide([price] -_price,_price)

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

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

August Carousel

Fabric Community Update - August 2024

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