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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Samoe
Advocate I
Advocate I

Durations between different status

Hi all,

I think I am stuck somewhere in my head, I think this should actually be easy to solve...

I have an excel sheet (example with random numbers here) which is used to track the leadtime. I have the date of each status change, the lot number associated to it and I created a calculated column to convert the statut text into a number bc I thought it might help.

How can I now create a measure that shows me the time passed between status 1-2, 2-3, 3-4 and 1-4 total for each no. lot? I cannot seem to get it. Also, ideally it is in weekdays (Monday-Friday)....

 

Samoe_0-1702055330206.png

Many thanks in advance for all help!

 

Edit: would if help if the data is ordered differently, with one line per no. lot and then each column header is a status and the dates of one no.lot are all in the same row?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Samoe 

You can create folloing measure

Measure =
VAR nextstepdate =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [No.lot]
                IN VALUES ( 'Table'[No.lot] )
                    && [Statut No]
                        = MAX ( 'Table'[Statut No] ) + 1
        ),
        [Date]
    )
RETURN
    IF (
        NOT ( ISBLANK ( nextstepdate ) ),
        DATEDIFF ( MAX ( 'Table'[Date] ), nextstepdate, DAY ),
        DATEDIFF (
            MINX (
                FILTER ( ALLSELECTED ( 'Table' ), [No.lot] IN VALUES ( 'Table'[No.lot] ) ),
                [Date]
            ),
            MAX ( 'Table'[Date] ),
            DAY
        )
    )

Output

vxinruzhumsft_0-1702448580300.png

Best Regards!

Yolo Zhu

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

4 REPLIES 4
mh2587
Super User
Super User

TimeBetweenStatus =//Try this one
VAR CurrentStatusNumber = MAX('LeadTime'[StatusNumber])
VAR NextStatusNumber =
CALCULATE(
MIN('LeadTime'[StatusNumber]),
'LeadTime'[StatusNumber] > CurrentStatusNumber
)
RETURN
IF(
ISBLANK(NextStatusNumber),
BLANK(),
CALCULATE (
MAX('LeadTime'[StatusDate]) - MAXX(
FILTER(
'LeadTime',
'LeadTime'[StatusNumber] = CurrentStatusNumber
),
'LeadTime'[StatusDate]
),
'LeadTime'[StatusNumber] = NextStatusNumber
)
)

Did I answer your question? If so, please mark my post as a solution!


Proud to be a Super User!




LinkedIn Icon
Muhammad Hasnain



Hi, thanks for the proposition! So far, it does not seem to work though... it returns nothing. How do I connect this calculation now to the NO.lot (the unique batch number)? 

Anonymous
Not applicable

Hi @Samoe 

You can create folloing measure

Measure =
VAR nextstepdate =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [No.lot]
                IN VALUES ( 'Table'[No.lot] )
                    && [Statut No]
                        = MAX ( 'Table'[Statut No] ) + 1
        ),
        [Date]
    )
RETURN
    IF (
        NOT ( ISBLANK ( nextstepdate ) ),
        DATEDIFF ( MAX ( 'Table'[Date] ), nextstepdate, DAY ),
        DATEDIFF (
            MINX (
                FILTER ( ALLSELECTED ( 'Table' ), [No.lot] IN VALUES ( 'Table'[No.lot] ) ),
                [Date]
            ),
            MAX ( 'Table'[Date] ),
            DAY
        )
    )

Output

vxinruzhumsft_0-1702448580300.png

Best Regards!

Yolo Zhu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hello ,

 

May I know how did u attach the Pbix here?

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.