The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.
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?
Solved! Go to Solution.
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
Proud to be a 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
Proud to be a Super User! | |
User | Count |
---|---|
68 | |
63 | |
59 | |
54 | |
28 |
User | Count |
---|---|
182 | |
81 | |
64 | |
46 | |
38 |