Forum Discussion
giovissimo
5 years agoHelper I
Problem Calculating the Kilometers driven
Hello, first of all, sorry if my problem has been solved already; I found a similar question, but not exactly the same. My table contains the following fields: Date (which is not relevant), Driver,...
v-yalanwu-msft
5 years agoCommunity Support
Hi giovissimo ,
You could create a measure by the following formula:
DrivenKms =
VAR _next =
CALCULATE (
MAX ( [TotalKms] ),
FILTER ( ALLEXCEPT ( 'Table', 'Table'[Car] ), [Date ] < EARLIER ( [Date ] ) ))
RETURN
IF ( [TotalKms] <> [TotalKms] - _next, [TotalKms] - _next )
The final output is shown below:
Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
giovissimo
5 years agoHelper I
Thank you for replying, nonetheless the error shown is the following (translated from Italian):
"EARLIER/EARLIEST refers to a previous row context which doesn't exist".
I'm at a loss to understand the reason of such a message.
Giovanni