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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
junaaaa
Regular Visitor

Subtracting the value of the odometer column based on the latest and oldest dates.

junaaaa_0-1697100850641.png

 

I have odometer values for various device names. I want to calculate the odometer value of the latest date minus the odometer value of the oldest date. How to calculate it with PowerBI?

1 ACCEPTED SOLUTION
dk_dk
Super User
Super User

Since the odometer value is increasing over time, it will be smallest at the oldest date and largest at the latest date, so you could just create a measure like this:

measure = MAX(Table[Value.data.odometer])-MIN(Table[Value.data.odometer]) and it should get you the correct calculation.

In case there is a scenario where the minimum and maximum values are not on the oldest and latest dates, you could use CALCULATE.

Something like this:

measure =
VAR earliest_value = CALCULATE(MIN(Table[Value.data.odometer]),Table[Value.data.received_at]=MIN(Table[Value.data.received_at]))

VAR latest_value= CALCULATE(MIN(Table[Value.data.odometer]),Table[Value.data.received_at]=MAX(Table[Value.data.received_at]))

RETURN
latest_value - earliest_value




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

Proud to be a Super User!





View solution in original post

1 REPLY 1
dk_dk
Super User
Super User

Since the odometer value is increasing over time, it will be smallest at the oldest date and largest at the latest date, so you could just create a measure like this:

measure = MAX(Table[Value.data.odometer])-MIN(Table[Value.data.odometer]) and it should get you the correct calculation.

In case there is a scenario where the minimum and maximum values are not on the oldest and latest dates, you could use CALCULATE.

Something like this:

measure =
VAR earliest_value = CALCULATE(MIN(Table[Value.data.odometer]),Table[Value.data.received_at]=MIN(Table[Value.data.received_at]))

VAR latest_value= CALCULATE(MIN(Table[Value.data.odometer]),Table[Value.data.received_at]=MAX(Table[Value.data.received_at]))

RETURN
latest_value - earliest_value




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

Proud to be a Super User!





Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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