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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Mattula
Frequent Visitor

Next Occurrence of value

I have a table of events and I want in a card to retrieve the next event which has the status 'Planned'. 

 

My table looks like this 

 

DateStatusEvent
11/12/2023ConfirmedEvent 1
12/12/2023ConfirmedEvent 2
13/12/2023CancelledEvent 3
14/12/2023ConfirmedEvent 4
15/12/2023PlannedEvent 5
16/12/2023CancelledEvent 6
17/12/2023PlannedEvent 7
18/12/2023NEWEvent 8
19/12/2023NEWEvent 9
20/12/2023PlannedEvent 10

 

I have used this Measure which is retrieving a value but isn't the next occuring event in the date order from today's date 

 

 

Next Event =
CALCULATE(MIN(TABLE1[EVENT]),
FILTER(
    TABLE1,
    TABLE1[EVENT_STATUS] = "Planning" &&
    TABLE1[Date] >= NOW()
)
)
1 ACCEPTED SOLUTION
vicky_
Super User
Super User

Here's the measure I have: 

 

Next Event = 
var earliestPlannedDate = CALCULATE(MIN('Table'[Date]), 'Table'[Date] >= TODAY() && 'Table'[Status] = "Planned")
return CALCULATE(MIN('Table'[Event]), 
    FILTER(
        'Table',
        'Table'[Date] = earliestPlannedDate
    )
)

 

Just a quick note - the TODAY() and NOW() functions are based on UTC time, but you should be able to find many threads on here about converting to local time. 

 

And the reason that your measure didn't work is because the MAX([Event]) will grab the first event alphabetically, so between events 7 and event 10, the "1" would come before "7", resulting in the incorrect result you saw above.

 

View solution in original post

2 REPLIES 2
vicky_
Super User
Super User

Here's the measure I have: 

 

Next Event = 
var earliestPlannedDate = CALCULATE(MIN('Table'[Date]), 'Table'[Date] >= TODAY() && 'Table'[Status] = "Planned")
return CALCULATE(MIN('Table'[Event]), 
    FILTER(
        'Table',
        'Table'[Date] = earliestPlannedDate
    )
)

 

Just a quick note - the TODAY() and NOW() functions are based on UTC time, but you should be able to find many threads on here about converting to local time. 

 

And the reason that your measure didn't work is because the MAX([Event]) will grab the first event alphabetically, so between events 7 and event 10, the "1" would come before "7", resulting in the incorrect result you saw above.

 

This worked perfectly. Thank you 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.