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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
elmarthg
Frequent Visitor

Calculating the duration of application stages

Hello,

 

I  need some help on trying to figure this out. I want to calculate how many days before the submitted applications gets approved or denied and to see if the submitted applications are moving to the next stage or are just stuck in the same status.. Please guide me to the right direction. 

 

 

regardingobjectidApplicationsCreatedOn
   
   
00224803D300Program 1 Submitted11/1/2022 16:31
002248081105Program 1 Denied11/9/2022 22:16
002248081105Program 1 Submitted9/20/2022 22:06
00224803D300Program 1 Submitted1/21/2023 0:01
000D3A3367BDProgram 1 Submitted12/23/2021 19:22
00224803D300Program 2 Submitted11/21/2022 17:22
00224803D300Program 3 Submitted11/21/2022 17:22
002248049AAAProgram 1 Approved2/7/2023 21:52
002248049AAAProgram 1 Submitted10/25/2022 18:30
00224803D300Program 1 Approved1/12/2023 0:10
00224803D300Program 1 Submitted11/1/2022 17:38
000D3A30ACEEProgram 2 Submitted12/21/2022 21:26

 

 

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @elmarthg 

 

You can try the following methods.

In the Power Query, sort the time column in ascending order and add the index column.

vzhangti_0-1678172430944.png

Column:

Previous time = 
CALCULATE (
    MAX ( 'Table'[CreatedOn] ),
    FILTER ( 'Table',
     [Regardingobjectid] = EARLIER ( 'Table'[Regardingobjectid] )
     &&[Index]<EARLIER('Table'[Index] ) ) )
Previous status = 
CALCULATE (
    MAX ( 'Table'[Applications] ),
    FILTER ( 'Table',
     [Regardingobjectid] = EARLIER ( 'Table'[Regardingobjectid] )
     &&[Index]<EARLIER('Table'[Index] ) ) )
Difference = DATEDIFF([Previous time],[CreatedOn],DAY)

vzhangti_1-1678173323276.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @elmarthg 

 

You can try the following methods.

In the Power Query, sort the time column in ascending order and add the index column.

vzhangti_0-1678172430944.png

Column:

Previous time = 
CALCULATE (
    MAX ( 'Table'[CreatedOn] ),
    FILTER ( 'Table',
     [Regardingobjectid] = EARLIER ( 'Table'[Regardingobjectid] )
     &&[Index]<EARLIER('Table'[Index] ) ) )
Previous status = 
CALCULATE (
    MAX ( 'Table'[Applications] ),
    FILTER ( 'Table',
     [Regardingobjectid] = EARLIER ( 'Table'[Regardingobjectid] )
     &&[Index]<EARLIER('Table'[Index] ) ) )
Difference = DATEDIFF([Previous time],[CreatedOn],DAY)

vzhangti_1-1678173323276.png

Is this the result you expect?

 

Best Regards,

Community Support Team _Charlotte

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

@elmarthg , Try a new column

 

var _max= maxx(filter(Table, [regardingobjectid] = earlier([regardingobjectid]) && [Applications] = earlier([Applications]) && [Status] ="Submitted"
&& [CreatedOn] < earlier([CreatedOn]) ), [CreatedOn])
return
if( [Status] in {"Approved", "Denied"}, datediff(_max, [CreatedOn], day), blank())

 

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

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

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors