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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
WHITE655
Regular Visitor

Consecutive Days Output

I am not sure where to start on this. 

 

I am wanting to have an output that will take the consecutive days down and total them up with the number of days "down". 

 

Attached the my sample data - The output wants is what I am wanting to calculate. 

 

Consecutive days down.jpg

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @WHITE655 

 

You can try the following methods.

Column:

Judge = 
DATEDIFF([Date]-2,MaxX(FILTER('Table',[Date]=EARLIER('Table'[Date])-1),[Date]),DAY)
First day = 
IF([Judge]<>BLANK(),0,1)
Consecutive days =
VAR last_1_date =
    CALCULATE (
        MAX ( 'Table'[date] ),
        FILTER (
            'Table',
            'Table'[date] <= EARLIER ( 'Table'[date] )
                && [First day] = 1
        )
    )
VAR sum_ =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            'Table',
            'Table'[date] >= last_1_date
                && 'Table'[date] <= EARLIER ( 'Table'[date] )
        )
    )
RETURN
    IF ( [First day] = 1, 1, sum_ )
Output =
VAR _N1 =
    CALCULATE (
        MIN ( 'Table'[date] ),
        FILTER ( 'Table', 'Table'[date] > EARLIER ( 'Table'[date] ) && [First day] = 1 )
    )
VAR _N2 =
    CALCULATE (
        MAX ( 'Table'[Consecutive days] ),
        FILTER ( 'Table', [Date] >= EARLIER ( 'Table'[Date] ) && [Date] <= _N1 )
    )
VAR _N3 =
    CALCULATE (
        MAX ( 'Table'[Consecutive days] ),
        FILTER ( 'Table', [Date] = MAX ( 'Table'[Date] ) )
    )
RETURN
    IF (
        [First day] = 1
            && _N1 <> BLANK (),
        _N2,
        IF ( [First day] = 1 && _N1 = BLANK (), _N3 )
    )

vzhangti_0-1650527855382.png

Is this the result you expect? Please refer to the attachment for details.

 

Best Regards,

Community Support Team _Charlotte

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

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @WHITE655 

 

You can try the following methods.

Column:

Judge = 
DATEDIFF([Date]-2,MaxX(FILTER('Table',[Date]=EARLIER('Table'[Date])-1),[Date]),DAY)
First day = 
IF([Judge]<>BLANK(),0,1)
Consecutive days =
VAR last_1_date =
    CALCULATE (
        MAX ( 'Table'[date] ),
        FILTER (
            'Table',
            'Table'[date] <= EARLIER ( 'Table'[date] )
                && [First day] = 1
        )
    )
VAR sum_ =
    CALCULATE (
        COUNTROWS ( 'Table' ),
        FILTER (
            'Table',
            'Table'[date] >= last_1_date
                && 'Table'[date] <= EARLIER ( 'Table'[date] )
        )
    )
RETURN
    IF ( [First day] = 1, 1, sum_ )
Output =
VAR _N1 =
    CALCULATE (
        MIN ( 'Table'[date] ),
        FILTER ( 'Table', 'Table'[date] > EARLIER ( 'Table'[date] ) && [First day] = 1 )
    )
VAR _N2 =
    CALCULATE (
        MAX ( 'Table'[Consecutive days] ),
        FILTER ( 'Table', [Date] >= EARLIER ( 'Table'[Date] ) && [Date] <= _N1 )
    )
VAR _N3 =
    CALCULATE (
        MAX ( 'Table'[Consecutive days] ),
        FILTER ( 'Table', [Date] = MAX ( 'Table'[Date] ) )
    )
RETURN
    IF (
        [First day] = 1
            && _N1 <> BLANK (),
        _N2,
        IF ( [First day] = 1 && _N1 = BLANK (), _N3 )
    )

vzhangti_0-1650527855382.png

Is this the result you expect? Please refer to the attachment for details.

 

Best Regards,

Community Support Team _Charlotte

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

amitchandak
Super User
Super User

@WHITE655 , to me, seems like a Continuous Streak problem

 

refer

https://community.powerbi.com/t5/Community-Blog/Power-BI-Continuous-Streak-With-One-Day-Break/ba-p/1...

 

Continuous streak : https://youtu.be/GdMcwvdwr0o

 

https://community.powerbi.com/t5/Desktop/Need-help-in-DAX/m-p/1277302#M559393

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

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.