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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

DAX Max Consecutive days run in Date Range Selected

HI Guys,

after some DAX help in solving a problem I have.

Basically its a table of dates and results and targets.

 

I need to get the maximum consecutive days that Targets have been met in the selected date range.

 

So looking at the data below.

With the entire set selected (22/5 - 10/6 ) it would be 5 days in a row that they have met targets of 0.75 (Or 75%) and above.

If the date range is altered to be from the 30/5 to 10/6 then it would just 3

and just possibly just 1 if it was from 06/06 to 8/06.

 

I know this is a island and gaps type problem and can solve it in SQL, but in DAX it has really stumped me, even after looking at other examples in the community pages re consecutive days.

 

The 'Result' column is a measure from a calculate but I've put in example below to simplify what Im trying to do.

As you can imagine this is very valuable information to the end user when they work with large date ranges of a year or so.

Also, Im using Direct query.

 

Any help welcomed.

Mike.

 

 

DateResultMet Target 0.75 and aboveTarget Run
22/05/20200.7N0
23/05/20200.72N0
24/05/20200.71N0
25/05/20200.78Y1
26/05/20200.79Y2
27/05/20200.81Y3
28/05/20200.77Y4
29/05/20200.76Y5
30/05/20200.71N0
1/06/20200.72N0
2/06/20200.71N0
3/06/20200.76Y1
4/06/20200.76Y2
5/06/20200.77Y3
6/06/20200.71N0
7/06/20200.72N0
8/06/20200.75Y1
9/06/20200.76Y2
10/06/20200.74N0

 

2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , refer if this can help

https://community.powerbi.com/t5/Desktop/Build-measure-or-column-to-show-a-streak-by-consecutive-dates-a/td-p/899915

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Ya,

thanks so much for the lead,

 

had a good look at their solution but that work for me as Im in Direct Query mode and 'calculate' isnt allowed in calculated columns so cannot even create the first column. Ended up putting the index into a SQL view to try and work that problem , but no luck.

Still looking at community pages for other solutions.

 

Mike.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors