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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
SAU1111
Frequent Visitor

Average Time between Repair Work orders

Hello All,

 

I have a table where cloumn1 = Porduct Name , Cloumn 2 = Serial Numbers of products , Cloumn 3 = Repair Work Order Numbers , Cloumn 4 = Work order Created date , Column 5 = Repair Work Order Closed Date . Now i have to find a time difference between last closed repair Work order date w.r.t previous repair closed date . Please suggest 

1 ACCEPTED SOLUTION

Hi @SAU1111 ,

If the Repair Work Order Numbers is random like below:

vkalyjmsft_0-1657592508991.png

You can create a column to rank the Closed Date for each Product Name and Serial Numbers of products, like this:

Rank =
RANKX (
    FILTER (
        'Table',
        'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
            && 'Table'[Serial Numbers of products]
                = EARLIER ( 'Table'[Serial Numbers of products] )
    ),
    'Table'[Repair Work Order Closed Date],
    ,
    ASC,
    DENSE
)

vkalyjmsft_1-1657592777416.png

Then create a measure.

Average Diff =
VAR _T =
    ADDCOLUMNS (
        'Table',
        "Diff",
            DATEDIFF (
                MAXX (
                    FILTER (
                        'Table',
                        'Table'[Rank]
                            = EARLIER ( 'Table'[Rank] ) - 1
                            && 'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
                            && 'Table'[Serial Numbers of products]
                                = EARLIER ( 'Table'[Serial Numbers of products] )
                    ),
                    'Table'[Repair Work Order Closed Date]
                ),
                'Table'[Repair Work Order Closed Date],
                DAY
            )
    )
RETURN
    AVERAGEX ( _T, [Diff] )

Get the result for each Product Name and Serial Numbers of products.

vkalyjmsft_2-1657592868772.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

View solution in original post

3 REPLIES 3
SAU1111
Frequent Visitor

Sorry I forgot to mention that for 1 Serial numbers there can be N numbers of Work orders and there closed On date . Now problem is that more than 1 serial numbers has same repair work order closed on date . SO WOrk order numbers also be random cannot be arranged as on same day two Work order of a sequence like 1 and 2 can be for different serial numbers . Now First how to arrange by Serial Numbers all the WO and its closed on Date so that i can arrange the dates in ascending order and calculate a difference . 

Hi @SAU1111 ,

If the Repair Work Order Numbers is random like below:

vkalyjmsft_0-1657592508991.png

You can create a column to rank the Closed Date for each Product Name and Serial Numbers of products, like this:

Rank =
RANKX (
    FILTER (
        'Table',
        'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
            && 'Table'[Serial Numbers of products]
                = EARLIER ( 'Table'[Serial Numbers of products] )
    ),
    'Table'[Repair Work Order Closed Date],
    ,
    ASC,
    DENSE
)

vkalyjmsft_1-1657592777416.png

Then create a measure.

Average Diff =
VAR _T =
    ADDCOLUMNS (
        'Table',
        "Diff",
            DATEDIFF (
                MAXX (
                    FILTER (
                        'Table',
                        'Table'[Rank]
                            = EARLIER ( 'Table'[Rank] ) - 1
                            && 'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
                            && 'Table'[Serial Numbers of products]
                                = EARLIER ( 'Table'[Serial Numbers of products] )
                    ),
                    'Table'[Repair Work Order Closed Date]
                ),
                'Table'[Repair Work Order Closed Date],
                DAY
            )
    )
RETURN
    AVERAGEX ( _T, [Diff] )

Get the result for each Product Name and Serial Numbers of products.

vkalyjmsft_2-1657592868772.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

 

v-yanjiang-msft
Community Support
Community Support

Hi @SAU1111 ,

According to your descrption, I create a sample.

vkalyjmsft_0-1657534908219.png

Here's my solution, create a measure.

Average Diff =
VAR _T =
    ADDCOLUMNS (
        'Table',
        "Diff",
            DATEDIFF (
                MAXX (
                    FILTER (
                        'Table',
                        'Table'[Repair Work Order Numbers]
                            = EARLIER ( 'Table'[Repair Work Order Numbers] ) - 1
                            && 'Table'[Porduct Name] = EARLIER ( 'Table'[Porduct Name] )
                            && 'Table'[Serial Numbers of products]
                                = EARLIER ( 'Table'[Serial Numbers of products] )
                    ),
                    'Table'[Repair Work Order Closed Date]
                ),
                'Table'[Repair Work Order Closed Date],
                DAY
            )
    )
RETURN
    AVERAGEX ( _T, [Diff] )

Get the correct result.

vkalyjmsft_1-1657534995788.png

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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