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
rebrow31
Helper I
Helper I

Return the next 20 events after one selected event

Hi, 

 

I have a list of downtime events of several machines. Some downtime events are planned and some are unplanned. I want to be able to select a specific planned downtime event, and then to see the next 20 downtime events that occured after the specific planned downtime event that I selected. How can I do this? 

1 ACCEPTED SOLUTION
Dangar332
Super User
Super User

Hi, @rebrow31 

 

Try below measure 

result = 
var a =CALCULATE(
    MIN('Table 2'[Value]),
    INDEX(
        20,
        FILTER(ALL('Table 2'[Machine],'Table 2'[Value]),'Table 2'[Value]>=MIN(Datetable[Date])),
        ORDERBY('Table 2'[Value],ASC),,
        PARTITIONBY('Table 2'[Machine]),
        MATCHBY('Table 2'[Machine],'Table 2'[Value])
    ),
    KEEPFILTERS(Datetable[Date])
)
var b= MIN('Table 2'[Value])+DATEDIFF(MIN(Datetable[Date]),a,DAY)
var c = CALCULATE(MAX('Table 2'[Value]),ALL('Table 2'[Value]))
var d= IF(ISBLANK(a),c,a)
var e= IF(ISFILTERED('Table 2'[Value]) && MIN('Table 2'[Value])>=SELECTEDVALUE(Datetable[Date]) && MIN('Table 2'[Value])<=d,1,0)
RETURN
e

i am taking data of machine and date 

consider table2[value] as your downtime date column

 

Dangar332_0-1712648924648.png

 

if after selected date you have less then 20 downtime field it also show that 
see below image

 

Dangar332_1-1712648948116.png

use measure in visual level filter

Dangar332_2-1712648987889.png

 

you can download file from below

 

 

 

View solution in original post

3 REPLIES 3
Dangar332
Super User
Super User

Hi, @rebrow31 

 

Try below measure 

result = 
var a =CALCULATE(
    MIN('Table 2'[Value]),
    INDEX(
        20,
        FILTER(ALL('Table 2'[Machine],'Table 2'[Value]),'Table 2'[Value]>=MIN(Datetable[Date])),
        ORDERBY('Table 2'[Value],ASC),,
        PARTITIONBY('Table 2'[Machine]),
        MATCHBY('Table 2'[Machine],'Table 2'[Value])
    ),
    KEEPFILTERS(Datetable[Date])
)
var b= MIN('Table 2'[Value])+DATEDIFF(MIN(Datetable[Date]),a,DAY)
var c = CALCULATE(MAX('Table 2'[Value]),ALL('Table 2'[Value]))
var d= IF(ISBLANK(a),c,a)
var e= IF(ISFILTERED('Table 2'[Value]) && MIN('Table 2'[Value])>=SELECTEDVALUE(Datetable[Date]) && MIN('Table 2'[Value])<=d,1,0)
RETURN
e

i am taking data of machine and date 

consider table2[value] as your downtime date column

 

Dangar332_0-1712648924648.png

 

if after selected date you have less then 20 downtime field it also show that 
see below image

 

Dangar332_1-1712648948116.png

use measure in visual level filter

Dangar332_2-1712648987889.png

 

you can download file from below

 

 

 

johnbasha33
Super User
Super User

@rebrow31 

You can achieve this by following these steps:

  1. Sort Downtime Events: First, sort your list of downtime events chronologically based on their timestamps.

  2. Identify Planned Downtime Event: Locate the specific planned downtime event that you've selected in the sorted list.

  3. Find Next 20 Downtime Events: Once you've located the selected planned downtime event, iterate through the sorted list to find the next 20 downtime events that occurred after the selected event.

Hi, 

 

Yes I can easily do this but it's a long winded way as there are so many downtime events. I want to be able to Pareto chart the next 20 downtime events after a selected stoppage and going through a massive list of downtime events doesn't work great. 

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.