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

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.

Reply
IbisRipley
Frequent Visitor

Need some help with methodology - calculate time in status of ordered list

I think this might be a simple question for many.  I have a table MyTable( status (INT) , Modified(DateTime) )  The statuses are ordered, but can be duplicated with multiple dates.

I am looking to show how long they are in each state, with the end goal to be aggrigating and charting Average time in a given status.  Can anyone point me in the right direction on methodology?  

Input table

Status     Modified

1             1/1/2020

2             1/3/2020

2              1/5/2020

3             1/6/2020

4             1/7/2020

 

Desired result

Status     TimeInStatus

1             2 (days)

2             3

3             1

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@IbisRipley 

Add this as a measure and check if it works for you:

Time In Status = 
VAR _STATUS = SELECTEDVALUE(MyTable[Status   ])
VAR _START = MIN(MyTable[ Modified])
VAR _END = MINX(FILTER(ALL(MyTable), MyTable[Status   ] > _STATUS ),MyTable[ Modified] )

RETURN
DATEDIFF( _START , _END ,DAY ) 

Fowmy_0-1604174088048.png

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@IbisRipley 

Add this as a measure and check if it works for you:

Time In Status = 
VAR _STATUS = SELECTEDVALUE(MyTable[Status   ])
VAR _START = MIN(MyTable[ Modified])
VAR _END = MINX(FILTER(ALL(MyTable), MyTable[Status   ] > _STATUS ),MyTable[ Modified] )

RETURN
DATEDIFF( _START , _END ,DAY ) 

Fowmy_0-1604174088048.png

 

________________________

If my answer was helpful, please consider Accept it as the solution to help the other members find it

Click on the Thumbs-Up icon if you like this reply 🙂

YouTube  LinkedIn

 



Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Thank you @Fowmy   I am almost there and appreciate your reply very much. 

I have used your suggestion as follows ( changed the DAY toMINUTE since test date is minimal and 

mostly created same day.

Time In Status = 
VAR _STATUS = SELECTEDVALUE(statusHistory[Status])
VAR _START = MIN(statusHistory[Modified].[Date])
VAR _END = MINX(FILTER(ALL(statusHistory), statusHistory[Status]> _STATUS ),statusHistory[Modified].[Date] )
RETURN
DATEDIFF( _START , _END ,MINUTE ) 

 Below is the output and source data.

 

I still have research to do but,   if I understand correctly, Do I need to add something to filter the start variable to the status grouping since all these are looking at the earliest regardless of status?

 

And the last thing I wondered is, if since what I want is a total of time in the status,  would I be better served doing this as a group by  in power query?

 

Thanks again for the help!  I will mark this answered since I was looking for guidance.

 

image.png

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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