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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Viranga
Frequent Visitor

Max consecutive day count by month in Power BI table

Hi,

 

I need to get the maximum consecutive day count according to the month. 

Ex: In June month, the max consecutive day count is 2.

     In August month, consecutive day counts are 2 and 3. The max consecutive day count is 3. (As in figure 03)

 

Viranga_1-1693220239615.png

 

Figure 02:

Viranga_0-1693220223024.png

 

Figure 03:

Viranga_2-1693220271856.png

 

Any help would be appreciated.

Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @Viranga ,

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1693382763025.png

2. Create calculated column.

Flag1 =
var _current=
MAXX(  FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])&&'Table'[Month]=EARLIER('Table'[Month])),[Date])
var _next=
MAXX(   FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])-1&&'Table'[Month]=EARLIER('Table'[Month])),[Date])
return
IF(
    _current-1 = _next,1,0)
Flag2 =
IF(
    [Flag1]=0,1,0)
Flag3 =
SUMX(
    FILTER(ALL('Table'),
    'Table'[Index]<=EARLIER('Table'[Index])&&'Table'[Month]=EARLIER('Table'[Month])),[Flag2])
Count =
 COUNTX(
     FILTER(ALL('Table'),
     'Table'[Month]=EARLIER('Table'[Month])&&'Table'[Flag3]=EARLIER('Table'[Flag3])),[Date])

3. Create calculated table.

Table 2 =
SUMMARIZE(
    'Table','Table'[Month],
    "Maximum Consecutive days",
    MAXX(
        FILTER(ALL('Table'),'Table'[Month]=EARLIER('Table'[Month])),[Count]))

4. Result:

vyangliumsft_1-1693382763025.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi  @Viranga ,

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1693382763025.png

2. Create calculated column.

Flag1 =
var _current=
MAXX(  FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])&&'Table'[Month]=EARLIER('Table'[Month])),[Date])
var _next=
MAXX(   FILTER(ALL('Table'),'Table'[Index]=EARLIER('Table'[Index])-1&&'Table'[Month]=EARLIER('Table'[Month])),[Date])
return
IF(
    _current-1 = _next,1,0)
Flag2 =
IF(
    [Flag1]=0,1,0)
Flag3 =
SUMX(
    FILTER(ALL('Table'),
    'Table'[Index]<=EARLIER('Table'[Index])&&'Table'[Month]=EARLIER('Table'[Month])),[Flag2])
Count =
 COUNTX(
     FILTER(ALL('Table'),
     'Table'[Month]=EARLIER('Table'[Month])&&'Table'[Flag3]=EARLIER('Table'[Flag3])),[Date])

3. Create calculated table.

Table 2 =
SUMMARIZE(
    'Table','Table'[Month],
    "Maximum Consecutive days",
    MAXX(
        FILTER(ALL('Table'),'Table'[Month]=EARLIER('Table'[Month])),[Count]))

4. Result:

vyangliumsft_1-1693382763025.png

 

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors
Top Kudoed Authors