I'm using Power BI (DAX) and I have a problem problem that I couldn't solve.
You can find below an exemple of my problem.
An ID is a workflow. I need to find the delay each time I have a status between the line of the status and the oldest line without a status, considering that the delay start again to the next line
ID | Time | Status | Result I want |
---|---|---|---|
ABC | 01/07/2020 04:07:00 | ||
ABC | 03/07/2020 04:14:00 | ||
ABC | 06/07/2020 06:27:00 | Done | 4,0917 |
XYZ | 11/06/2020 04:03:00 | ||
XYZ | 12/06/2020 04:02:00 | To check | 0,9993 |
XYZ | 15/06/2020 04:02:00 | ||
XYZ | 16/06/2020 04:04:00 | Transfered | 1,0014 |
XYZ | 17/06/2020 04:14:00 | ||
XYZ | 21/06/2020 04:34:00 | ||
XYZ | 30/06/2020 04:14:00 | Done | 13,0000 |
MON | 07/09/2020 09:49:00 | Cancelled | 0,0000 |
What I did was created an another column Filter 1 and Filter 2 to create an index like below
ID | Time | Status | Filter1 | Filter2 |
---|---|---|---|---|
ABC | 01/07/2020 04:07:00 | 0 | 1 | |
ABC | 03/07/2020 04:14:00 | 0 | 1 | |
ABC | 06/07/2020 06:27:00 | Done | 1 | 1 |
XYZ | 11/06/2020 04:03:00 | 0 | 3 | |
XYZ | 12/06/2020 04:02:00 | To check | 1 | 3 |
XYZ | 15/06/2020 04:02:00 | 0 | 2 | |
XYZ | 16/06/2020 04:04:00 | Transfered | 1 | 2 |
XYZ | 17/06/2020 04:14:00 | 0 | 1 | |
XYZ | 21/06/2020 04:34:00 | 0 | 1 | |
XYZ | 30/06/2020 04:14:00 | Done | 1 | 1 |
MON | 07/09/2020 09:49:00 | Cancelled | 1 | 1 |
The formula for filter1 is :IF('test communauté'[Filter0]="YES",IF('test communauté'[Status]=BLANK(),0,1),0)
For Filter 2 is :
VAR currentid = 'test communauté'[ID]
VAR maxtime = VALUE(CALCULATE(MAX('test communauté'[Time]),'test communauté'[ID]=currentid))
VAR test = SUMX(
FILTER ( 'test communauté',
'test communauté'[Time] >= maxtime
&& 'test communauté'[ID] = currentid
&& 'test communauté'[Filter0] = "YES"
),
'test communauté'[Filter1])
return test
And when I try to use this column filter2 to create a formula for my delay, I have a circular dependency. I don't know how to avoid this error. Keep in mind that I need the delay in column in the end and not as a measure because I will need it to calculate other KPI.
Thank you for your help,
Best regards, Alex
You can use REMOVEFILTERS in maxtime to remove the dependency of Filter2 from Filter1
Filter 2 =
VAR currentid = 'test communauté'[ID]
VAR maxtime =
VALUE (
CALCULATE (
MAX ( 'test communauté'[Time] ),
'test communauté'[ID] = currentid,
REMOVEFILTERS ( 'test communauté'[Filter1] )
)
)
VAR test =
SUMX (
FILTER (
'test communauté',
'test communauté'[Time] >= maxtime
&& 'test communauté'[ID] = currentid
&& 'test communauté'[Filter0] = "YES"
),
'test communauté'[Filter1]
)
RETURN
test
Also read these posts: