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
tblackburn
Regular Visitor

Calculate days in current process step

Hi,

 

I'm trying to calculate the days each Work Order has spent in its current Process Step. The data is automatically appended every morning. Below is an example of the data for each Work Order, the last column (Days in Current Process Step) is what I'm trying to calculate automatically.

 

In reality this data set has multiple Work Orders for each day.

 

Sample Data.png

 

 

 

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @tblackburn,

 

Please create calculated columns using below DAX formulas in source table (in my test, it's named as 'Work Order').

New Col1 =
VAR lastdaypull =
    CALCULATE (
        MAX ( 'Work Order'[Day Pulled] ),
        ALLEXCEPT ( 'Work Order', 'Work Order'[Work Order] ),
        'Work Order'[Day Pulled] < EARLIER ( 'Work Order'[Day Pulled] )
    )
RETURN
    IF (
        CALCULATE (
            LASTNONBLANK ( 'Work Order'[Current Process Step], 1 ),
            FILTER (
                ALLEXCEPT ( 'Work Order', 'Work Order'[Work Order] ),
                'Work Order'[Day Pulled] = lastdaypull
            )
        )
            <> 'Work Order'[Current Process Step],
        1,
        0
    )

New Col2 = CALCULATE ( SUM ( 'Work Order'[New Col1] ), FILTER ( ALLEXCEPT ( 'Work Order', 'Work Order'[Work Order] ), 'Work Order'[Day Pulled] <= EARLIER ( 'Work Order'[Day Pulled] ) ) )
Days in Current Process Step = RANKX ( FILTER ( 'Work Order', 'Work Order'[Work Order] = EARLIER ( 'Work Order'[Work Order] ) && 'Work Order'[New Col2] = EARLIER ( 'Work Order'[New Col2] ) ), 'Work Order'[Day Pulled], , ASC, DENSE )

1.PNG

 

As resource data is automatically appended every morning, each time you open this report, please refresh report page manually, the table view will be updated to latest data.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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
v-yulgu-msft
Employee
Employee

Hi @tblackburn,

 

Please create calculated columns using below DAX formulas in source table (in my test, it's named as 'Work Order').

New Col1 =
VAR lastdaypull =
    CALCULATE (
        MAX ( 'Work Order'[Day Pulled] ),
        ALLEXCEPT ( 'Work Order', 'Work Order'[Work Order] ),
        'Work Order'[Day Pulled] < EARLIER ( 'Work Order'[Day Pulled] )
    )
RETURN
    IF (
        CALCULATE (
            LASTNONBLANK ( 'Work Order'[Current Process Step], 1 ),
            FILTER (
                ALLEXCEPT ( 'Work Order', 'Work Order'[Work Order] ),
                'Work Order'[Day Pulled] = lastdaypull
            )
        )
            <> 'Work Order'[Current Process Step],
        1,
        0
    )

New Col2 = CALCULATE ( SUM ( 'Work Order'[New Col1] ), FILTER ( ALLEXCEPT ( 'Work Order', 'Work Order'[Work Order] ), 'Work Order'[Day Pulled] <= EARLIER ( 'Work Order'[Day Pulled] ) ) )
Days in Current Process Step = RANKX ( FILTER ( 'Work Order', 'Work Order'[Work Order] = EARLIER ( 'Work Order'[Work Order] ) && 'Work Order'[New Col2] = EARLIER ( 'Work Order'[New Col2] ) ), 'Work Order'[Day Pulled], , ASC, DENSE )

1.PNG

 

As resource data is automatically appended every morning, each time you open this report, please refresh report page manually, the table view will be updated to latest data.

 

Regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you! Works like a charm!

tblackburn
Regular Visitor

Help me...someone...you're my only hope!

Hello!
Try this formula of calculate column

Days in Current Process Step =
CALCULATE (
    COUNTROWS ( Table ),
    FILTER (
        Table,
        Table[Day Pulled] <= EARLIER ( Table[Day Pulled] )
            && Table[Work order] = EARLIER ( Table[Work order] )
            && Table[Product Name] = EARLIER ( Table[Product Name] )
            && Table[Serial Number] = EARLIER ( Table[Current Process Step] )
            && Table[Current Process Step] = EARLIER ( Table[Current Process Step] )
    )
)

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.