Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi all,
I have a relation that contains statuses of a process. I'm only given a createDateTime and need to make some visualization that counts the statuses that ended today.
My data looks like this:
The assumption is that, if the column IsCurrentStatus is NOT equal to 0, the next createDateTime should become the endDateTime for that row. And this needs to be done for each ProcessId individually.
Note: I've shown the createDateTimes sorted per processId in ascending order to easily demonstrate the problem, but this is not a given in my dataset.
Already a huge thanks in advance for the hero that can solve this 🙂
Best, Joep
Solved! Go to Solution.
Hi @Anonymous ,
According to your needs, I did the following test, the created measures are grouped according to Processid, and satisfy if the column IsCurrentStatus is NOT equal to 0, the next createDateTime should become the endDateTime for that row. Refer to the screenshot below:
endDateTime =
VAR cur_index =
MIN ( 'Table'[Index] ) + 1
VAR pre_index =
CALCULATE (
MAX ( 'Table'[Index] ),
FILTER (
ALL ( 'Table' ),
'Table'[processID] = MAX ( 'Table'[processID] )
&& 'Table'[Index] <= cur_index
)
)
RETURN
IF (
MAX ( 'Table'[lsCurrentStatus] ) = 1,
BLANK (),
CALCULATE (
MIN ( 'Table'[createDateTime] ),
FILTER (
ALL ( 'Table' ),
MAX ( 'Table'[processID] ) = 'Table'[processID]
&& 'Table'[Index] = pre_index
)
)
)
Here is the sample pbix file.
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
According to your needs, I did the following test, the created measures are grouped according to Processid, and satisfy if the column IsCurrentStatus is NOT equal to 0, the next createDateTime should become the endDateTime for that row. Refer to the screenshot below:
endDateTime =
VAR cur_index =
MIN ( 'Table'[Index] ) + 1
VAR pre_index =
CALCULATE (
MAX ( 'Table'[Index] ),
FILTER (
ALL ( 'Table' ),
'Table'[processID] = MAX ( 'Table'[processID] )
&& 'Table'[Index] <= cur_index
)
)
RETURN
IF (
MAX ( 'Table'[lsCurrentStatus] ) = 1,
BLANK (),
CALCULATE (
MIN ( 'Table'[createDateTime] ),
FILTER (
ALL ( 'Table' ),
MAX ( 'Table'[processID] ) = 'Table'[processID]
&& 'Table'[Index] = pre_index
)
)
)
Here is the sample pbix file.
If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.
Best Regards,
Henry
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Anonymous , Create a new column for end time
new column =
var _1 = mix(filter(Table, [processId] = earlier([processId]) && [statusId]> earlier([statusId])),[statusId])
return
if([statusId]<> 0 , _1, blank())
Thanks for your quick and helpful reply @amitchandak! What does the mix-function do? My PowerBI query editor returns "Cannot find name 'mix'. 'mix' is not a function.". Googling for the mix-function didn't return any helpful results either..
Best,
Joep
@Anonymous , Sorry, typo mistake (MinX)
new column =
var _1 = minx(filter(Table, [processId] = earlier([processId]) && [statusId]> earlier([statusId])),[statusId])
return
if([statusId]<> 0 , _1, blank())
Thanks for your fix! Unfortunately, this does not result in the desired column (WANTED: endDateTime) as shown in the picture. Any solutions how to get to that desired result?
Best, Joep
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
95 | |
94 | |
80 | |
71 | |
64 |
User | Count |
---|---|
120 | |
105 | |
99 | |
81 | |
72 |