In the attached Pbix I want to create a measure to
to replace the result from the calculated column " DIFF in day JOB and unit NO"
but fail to find the create the measure. I always get an error with the earlier() function.
the result of the calculated column is correct.
maybe there is another simplier solution to solve this.
aim is to calculate the number of days for a JOB & UNIT_NO combination.
Once the measure is created I can copy it to calculate the difference of the km_meter
Keith
thanks for your answer, but the dax works fine in the calculated column, so I don’t think
that’s the problems, I did use the chatTGPT for alternative for the earlier function but with no success. I will review the webinar
Hi @Roger. I’m guessing that the EARLIER function works in row context (your calculated column) but not in filter context (your measure). I’ve been using Power BI several hours just about every day for the past 4-5 years and have never used (and only very rarely seen) the EARLIER function … AFAIK it’s a best practice to not use it (I thought it was legacy and that it had been deprecated). Greg
Honnered to get an answer from Greg and thanks for the reply.
Does this mean that I can not create a measure to solve this problem?
Is there a workarround for this to not use the earlier function ?
As I noted before, I’m unfamiliar with the EARLIER function so don’t know any workarounds. That being said, there are mutiple ways to refer to other rows in a visual that may be useful. Here’s an article I posted a few years ago that may provide some insight:
As well, possibly the recently released WINDOW functions in DAX may help.
Here’s a quick draft of a measure that produces the same result, but not sure I understand your existing logic (there seem to be multiple rows for each UNIT NO/JOB combination, so …)
Greg
thanks for the solution, it works great and it’s a simple pattern to use in the future pbix files.
As always great support on the platform and an impressive content to learn from