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
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
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.