Forum Discussion
Total average of datediff
- 2 years ago
Hi Jodallen123
Try this:
PL handling time = AVERAGEX ( VALUES ( 'logs'[Ordernumber] ), VAR minbookedmeeting = CALCULATE ( MIN ( 'logs'[Created_date] ), 'logs'[status_changed_to] = "B" || 'logs'[status_changed_to] = "C" ) VAR maxcustomerdone = CALCULATE ( MAX ( 'logs'[Created_date] ), 'logs'[status_changed_to] = "D" || 'logs'[status_changed_to] = "E" ) VAR datedifference = maxcustomerdone - minbookedmeeting RETURN datedifference )It's essentially the same code as you had, but wrapped in AVERAGEX ( VALUES (... ), ... )
AVERAGEX ( VALUES ( 'logs'[Ordernumber] ), <your original code> )This will compute the datedifference for each Ordernumber, then return the arithmetic mean of these values.
For simplicity, I also suggest subtracting the dates rather than using DATEDIFF (they are both valid though).
Does this work for you?
Regards
Hi Jodallen123
Try this:
PL handling time =
AVERAGEX (
VALUES ( 'logs'[Ordernumber] ),
VAR minbookedmeeting =
CALCULATE (
MIN ( 'logs'[Created_date] ),
'logs'[status_changed_to] = "B"
|| 'logs'[status_changed_to] = "C"
)
VAR maxcustomerdone =
CALCULATE (
MAX ( 'logs'[Created_date] ),
'logs'[status_changed_to] = "D"
|| 'logs'[status_changed_to] = "E"
)
VAR datedifference = maxcustomerdone - minbookedmeeting
RETURN
datedifference
)
It's essentially the same code as you had, but wrapped in AVERAGEX ( VALUES (... ), ... )
AVERAGEX (
VALUES ( 'logs'[Ordernumber] ),
<your original code>
)
This will compute the datedifference for each Ordernumber, then return the arithmetic mean of these values.
For simplicity, I also suggest subtracting the dates rather than using DATEDIFF (they are both valid though).
Does this work for you?
Regards
Thank you!!
I tried the code just like you wrote it, which didn't give the correct values but when i tried using datediff instead of subtracting the dates, it does work. It is very possible that I am doing something else wrong when I am subtracting the values but I am just glad it works now!