Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Generate an endDateTime based on createDateTime

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:

JoepBI_0-1614861582202.png

 

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

 

 

1 ACCEPTED SOLUTION
v-henryk-mstf
Community Support
Community Support

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
            )
        )
    )

v-henryk-mstf_0-1615365370556.png

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.

View solution in original post

5 REPLIES 5
v-henryk-mstf
Community Support
Community Support

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
            )
        )
    )

v-henryk-mstf_0-1615365370556.png

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.

amitchandak
Super User
Super User

@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())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

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())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.