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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.