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

Share with Power BI Enthusiasts: 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
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.