Hopefully others have encountered this situation.
There's a lot I need to wrap my head around in DAX and the order that calculations happen is one of them. I'm not sure whether the following measure is doing what I think it's doing without having to create multiple intermediate helper columns in a very large table.
I have 4 date events and I want to track each duration between them. The first event always has a date but the middle 2 events are optional and the last may be delayed.
Voucher Entry -> Voucher Match -> Voucher Approval -> Voucher Paid
The final objective is to generate a pivot table showing the average lag times for each step (where the event happened) to end as a stacked bar chart. So I will be able to tell how long each step of the voucher payment process takes based on whatever filter type I choose (e.g. by vendor).
This particular measure is supposed to tell me, if there is an Approval date, how long it happened after the latest prior event. In this case I'm expecting CompleteDate to be recalculated for every row of the filtered table within the AVERAGEX statement. Is it? The syntax doesn't generate an error, but as I say it's hard to tell without creating a bunch of helper columns if I'm getting the value I expect.
There's a lot I need to wrap my head around in DAX and the order that calculations happen is one of them. I'm not sure whether the following measure is doing what I think it's doing without having to create multiple intermediate helper columns in a very large table.
I have 4 date events and I want to track each duration between them. The first event always has a date but the middle 2 events are optional and the last may be delayed.
Voucher Entry -> Voucher Match -> Voucher Approval -> Voucher Paid
The final objective is to generate a pivot table showing the average lag times for each step (where the event happened) to end as a stacked bar chart. So I will be able to tell how long each step of the voucher payment process takes based on whatever filter type I choose (e.g. by vendor).
This particular measure is supposed to tell me, if there is an Approval date, how long it happened after the latest prior event. In this case I'm expecting CompleteDate to be recalculated for every row of the filtered table within the AVERAGEX statement. Is it? The syntax doesn't generate an error, but as I say it's hard to tell without creating a bunch of helper columns if I'm getting the value I expect.
Code:
Avg Lag Approval Days :=CALCULATE (
AVERAGEX (
Vouchers,
VAR CompleteDate =
IF (
ISBLANK ( Vouchers[Voucher Match Date] ),
Vouchers[Voucher Entered Date],
Vouchers[Voucher Match Date]
)
RETURN
Vouchers[Voucher Approval Date] - CompleteDate
),
FILTER (
Vouchers,
NOT (
ISBLANK ( Vouchers[Voucher Approval Date] )
)
)
)