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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate Difference between multiple rows in table

Hi

 

I have a table with two columes, Month and Value. 

I want to create a third column that calculate the difference between the first value (lowest date) and current value.

The measure must be dynamic since the dates is adjustable. (See below where desired result of difference is shown)

 

I try using below dax for mindate but only recieve same date as selected row (e.g. 2302 at row 2302 when I want to recieve 2301 to be able to compare with this basevalue). Do I need to replace "Allselected" with somethingelse?

CALCULATE(min('Date'[MonthSort]),ALLSELECTED('Date'[Date]))

 

Example:

YearMonth   Value  Difference

2301             10       0 (10-10)

2302             12       2 (12-10)

2303             8         -2 (8-10) 

2304             11        1 (11-10)

3 REPLIES 3
Tahreem24
Super User
Super User

@Anonymous Use the below Column:

 
Column =
VAR Prev = CALCULATE(SUM(MyTable[Value]),FILTER(ALL(MyTable),MyTable[MonthYear]=MIN(MyTable[MonthYear])))
RETURN MyTable[Value]-Prev
 
Tahreem24_1-1694512082431.png

 

 
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
CoreyP
Solution Sage
Solution Sage

I think you need to use ALL.

Anonymous
Not applicable

Hi @CoreyP 

Unfortunately, that return the same result as Allselected

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.