Forum Discussion
timcorke
4 years agoHelper I
Date differences between dates with different status
Good afternoon, I'm hoping you could help me. For each individual [UID] there are different status changes [ACTIVITY_TYPE] made up of REQUESTED, RESPONDED, CLOSED, CANCELLED based on the progres...
- 4 years ago
Hi,
Please check the below picture and the attached pbix file.
Expected result: = VAR firstrequesteddate = MINX ( FILTER ( Data, Data[UID] = MAX ( Data[UID] ) && Data[ACTIVITY_TYPE] = "REQUESTED" ), Data[ACTIVITY_DATE] ) VAR firstrespondeddate = MINX ( FILTER ( Data, Data[UID] = MAX ( Data[UID] ) && Data[ACTIVITY_TYPE] = "RESPONDED" ), Data[ACTIVITY_DATE] ) RETURN VALUE ( firstrespondeddate - firstrequesteddate ) - 4 years ago
If you mean to create a calculated column, here is a similar apporach:
DaysToFirstResponse = VAR FirstRequestDate = CALCULATE ( MIN ( 'Table'[ACTIVITY_DATE] ), ALLEXCEPT ( 'Table', 'Table'[UID] ), 'Table'[ACTIVITY_TYPE] = "REQUESTED" ) VAR FirstResponseDate = CALCULATE ( MIN ( 'Table'[ACTIVITY_DATE] ), ALLEXCEPT ( 'Table', 'Table'[UID] ), 'Table'[ACTIVITY_TYPE] = "RESPONDED" ) RETURN DATEDIFF ( FirstRequestDate, FirstResponseDate, DAY )
Sample file available here.
Please mark this as a solution if it resolved your issue.
Regards
timcorke
4 years agoHelper I
Many thanks for your time responding, this is really helpful thank you.
My only additional query is if there is no REQUESTED or RESPONDED. Looking deeper n the data identifies that many records, likely historical, have just CLOSED or CANCELLED so return 44124 or similar negative value as there are no dates to use.
BarnabasToth
4 years agoResolver I
For me it returns BLANK ( ) when REQUESTED or RESPONDED is missing.