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
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors