cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
shilunannan
New Member

how to calculate difference between two rows in a table ?

Hi, 

 

Any help is appreciated. I'm creating a dashboard to display pricing info. With selecting two price curves, the corresponding grades are displayed in the table beside it. I'm wondering if there is a way to show the difference between selected two grades?

 

shilunannan_0-1614888916375.png

 

And here is my sample table. 

 

EOD DateGrid Point MonthPrice CurvePrice
3/1/20213/1/2021C5-CRW0.9
3/1/20214/1/2021C5-CRW1.5
3/1/20215/1/2021C5-CRW0.7
3/1/20216/1/2021C5-CRW0.2
3/1/20217/1/2021C5-CRW-1.5
3/1/20218/1/2021C5-CRW-1.6
3/1/20219/1/2021C5-CRW-1.7
3/1/202110/1/2021C5-CRW-1.2
3/1/202111/1/2021C5-CRW-1.2
3/1/202112/1/2021C5-CRW-1.2
3/1/20211/1/2022C5-CRW-1.75
3/1/20212/1/2022C5-CRW-1.75
3/1/20213/1/2022C5-CRW-1.75
3/1/20214/1/2022C5-CRW-2.75
3/1/20215/1/2022C5-CRW-2.75
3/1/20216/1/2022C5-CRW-2.75
3/1/20217/1/2022C5-CRW-4.1
3/1/20218/1/2022C5-CRW-4.1
3/1/20219/1/2022C5-CRW-4.1
3/1/202110/1/2022C5-CRW-3.6
3/1/202111/1/2022C5-CRW-3.6
3/1/202112/1/2022C5-CRW-3.6

 

 

Really appreciated! 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @shilunannan ,

 

Create a measure as below:

Measure = 
IF(ISINSCOPE('Table'[Price Curve]),
SUM('Table'[Price]),
CALCULATE(SUM('Table'[Price]),FILTER(ALLSELECTED('Table'),'Table'[Price Curve]=MAX('Table'[Price Curve])&&'Table'[EOD Date]=MAX('Table'[EOD Date])))-CALCULATE(SUM('Table'[Price]),FILTER(ALLSELECTED('Table'),'Table'[Price Curve]=Min('Table'[Price Curve])&&'Table'[EOD Date]=MAX('Table'[EOD Date]))))

And you will see:

v-kelly-msft_0-1615186896104.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

2 REPLIES 2
v-kelly-msft
Community Support
Community Support

Hi @shilunannan ,

 

Create a measure as below:

Measure = 
IF(ISINSCOPE('Table'[Price Curve]),
SUM('Table'[Price]),
CALCULATE(SUM('Table'[Price]),FILTER(ALLSELECTED('Table'),'Table'[Price Curve]=MAX('Table'[Price Curve])&&'Table'[EOD Date]=MAX('Table'[EOD Date])))-CALCULATE(SUM('Table'[Price]),FILTER(ALLSELECTED('Table'),'Table'[Price Curve]=Min('Table'[Price Curve])&&'Table'[EOD Date]=MAX('Table'[EOD Date]))))

And you will see:

v-kelly-msft_0-1615186896104.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

amitchandak
Super User
Super User

@shilunannan , You can have to create a measure like

 

new measure =
var _min = minx(allselected(Table), Table[Price Curve])
var _max = maxx(allselected(Table), Table[Price Curve])
return
calculate(Average(Table[Price]), filter(Table, Table[Price Curve] =_max)) -calculate(Average(Table[Price]), filter(Table, Table[Price Curve] =_min))



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s || 50+Power Query List Functions : Learn Power Query List
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Helpful resources

Announcements
September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Dev Camp Session 26

Check it Out!

Mark your calendars and join us on Thursday, September 29 at 11a PDT for a great session with Ted Pattison!

Top Solution Authors