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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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