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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Smallegrue
Frequent Visitor

Referencing rows within same table based on events

Hello all,

 

I've been having trouble with this and I can't seem to figure it out.

 

I have an equipement status table that records a row everytime an equipement status changes or at the end of a shift. It currently looks like this:

 

Row IDDateEquipmentShiftTimeDurationStatus
12020-02-17T101Night0:0043200Up
22020-02-18T101Day0:0021600Up
32020-02-18T101Day6:0010800Down
42020-02-18T101Day9:0010800Up
52020-02-18T101Night0:0043200Down
62020-02-19T101Day0:0043200Down
72020-02-19T101Night0:0043200Down
82020-02-20T101Day0:0043200Down
92020-02-20T101Night0:0043200Down

 

The problem is we are trying to calculate the mean time to repair. If you notice the last 5 rows of the table are all associated to the same failure. Ideally, I would like to add a column that would associate the root failure based on the previous status change/not change. Something like this:

 

Row IDDateEquipmentShiftTimeDurationStatusOriginal Failure line ID
12020-02-17T101Night0:0043200Up 
22020-02-18T101Day0:0021600Up 
32020-02-18T101Day6:0010800Down3
42020-02-18T101Day9:0010800Up 
52020-02-18T101Night0:0043200Down5
62020-02-19T101Day0:0043200Down5
72020-02-19T101Night0:0043200Down5
82020-02-20T101Day0:0043200Down5
92020-02-20T101Night0:0043200Down5

 

Can someone please help me out with this I can't figure it out.

 

Thank you,

 

Steph

1 ACCEPTED SOLUTION

Hi @Smallegrue ,

 

We can create a calculated column to meet your requirement:

 

Original Failure line ID =
IF (
    [Status] = "Down",
    CALCULATE (
        MIN ( 'Table'[Row ID] ),
        FILTER (
            'Table',
            'Table'[Row ID]
                > CALCULATE (
                    MAX ( 'Table'[Row ID] ),
                    FILTER (
                        'Table',
                        'Table'[Row ID] <= EARLIER ( 'Table'[Row ID], 2 )
                            && 'Table'[Status] = "Up"
                    )
                )
                && 'Table'[Status] = "Down"
        )
    )
)

 

 

13.jpg
Best regards,

 

Community Support Team _ Dong Li
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
Greg_Deckler
Super User
Super User

See my article on Mean Time Between Failure (MTBF) which uses EARLIER: http://community.powerbi.com/t5/Community-Blog/Mean-Time-Between-Failure-MTBF-and-Power-BI/ba-p/3395...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Hello,

 

So I looked at @Greg_Deckler post and although it is a start, I feel it's not exactly the same thing. I maybe mistaken, but I feel Greg's post deals with rows that are independant of each other vs my rows are dependant on each other...the lenght of a failure could be the sum of multiple durations of subsequent lines. In greg's case each line represents a distinct failure.

 

Using Greg's post I was able to "tag" failing lines, but I'm not able to distinct each failure.

 

Here is the closest result I was able to obtain...

 

Original Failure Line ID =
minx(
filter(
'Status Equipements',
'Status Equipements'[Equipment] = EARLIER('Status Equipements'[Equipment])
&& 'Status Equipements'[Status] = EARLIER('Status Equipements'[status])
&& 'Status Equipements'[Status] = "Down"
&& 'Status Equipements'[Row ID] <= earlier('Status Equipements'[Row ID])
 
),
'Status Equipements'[Row ID]
)

 

 

Row IDDateEquipmentShiftTimeDurationStatusOriginal Failure line ID
12020-02-17T101Night0:0043200Up 
22020-02-18T101Day0:0021600Up 
32020-02-18T101Day6:0010800Down3
42020-02-18T101Day9:0010800Up 
52020-02-18T101Night0:0043200Down3
62020-02-19T101Day0:0043200Down3
72020-02-19T101Night0:0043200Down3
82020-02-20T101Day0:0043200Down3
92020-02-20T101Night0:0043200Down3

 

 

Any help is appreciated

Hi @Smallegrue ,

 

We can create a calculated column to meet your requirement:

 

Original Failure line ID =
IF (
    [Status] = "Down",
    CALCULATE (
        MIN ( 'Table'[Row ID] ),
        FILTER (
            'Table',
            'Table'[Row ID]
                > CALCULATE (
                    MAX ( 'Table'[Row ID] ),
                    FILTER (
                        'Table',
                        'Table'[Row ID] <= EARLIER ( 'Table'[Row ID], 2 )
                            && 'Table'[Status] = "Up"
                    )
                )
                && 'Table'[Status] = "Down"
        )
    )
)

 

 

13.jpg
Best regards,

 

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

Thanks Greg,

 

I'll take a look at it! I'll let you know.

Helpful resources

Announcements
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.