cancel
Showing results for
Did you mean:
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.

1 ACCEPTED SOLUTION

Accepted Solutions
Microsoft

## Re: Calculate days in current process step

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

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.
4 REPLIES 4
Regular Visitor

## Re: Calculate days in current process step

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

Resolver III

## Re: Calculate days in current process step

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

Microsoft

## Re: Calculate days in current process step

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

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

## Re: Calculate days in current process step

Thank you! Works like a charm!

Announcements

#### Announcing the New Spanish Forum

Do you need help in Spanish? Check out our new Spanish community section.

#### April 2020 Community Highlights

Info on our Super Users, MBAS content and badges, and updates to our support articles. - Read the full Community Highlights.

#### MBAS Gallery 2020

Watch Microsoft Business Applications Summit sessions on-demand.

Top Solution Authors
Top Kudoed Authors