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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Consecutive Working Days

Hi, 

 

I am trying to calculate the number of consecutive working days from current date/day based off the working hours column - if they have recorded time in here or it reads 0/null.

 

Example data set would be - with todays date being 28/02/2022 for example

Date (Date)ID (Text)

Working Hours (Time)

15/02/2022

1001

01:54
16/02/2022100111:21
17/02/2022100116:18
18/02/2022100114:11
19/02/2022100110:23
20/02/2022100107:46
21/02/2022100100:00
22/02/2022

1001

 
23/02/2022100111:21
24/02/2022100111:41
25/02/2022100115:31
26/02/2022100110:57
27/02/2022100108:57
28/02/20221001 

 

Expected output for KPI card would be 5 consecutive working days. 

 

Thanks

Chris

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

Here's the measure which returns the result.

Consecutive Working Days =
VAR _today =
    TODAY()
VAR _lastblank =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [ID (Text)] = MAX ( 'Table'[ID (Text)] )
                && [Date (Date)] < _today
                && [Working Hours (Time)] = BLANK ()
        ),
        [Date (Date)]
    )
RETURN
    COUNTROWS (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [ID (Text)] = MAX ( 'Table'[ID (Text)] )
                && [Date (Date)] > _lastblank
                && [Date (Date)] < _today
        )
    )

To illustrate the expected outcome, I replaced TODAY() with DATE(2022,2,28).

6.png

Here's the result. For ID 1001, the consecutive working days is 5 and for ID 1002 is 2.

vstephenmsft_1-1679466909849.png

 

Best Regards,

Stephen Tao

 

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

3 REPLIES 3
Anonymous
Not applicable

Hi @Anonymous ,

 

Here's the measure which returns the result.

Consecutive Working Days =
VAR _today =
    TODAY()
VAR _lastblank =
    MAXX (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [ID (Text)] = MAX ( 'Table'[ID (Text)] )
                && [Date (Date)] < _today
                && [Working Hours (Time)] = BLANK ()
        ),
        [Date (Date)]
    )
RETURN
    COUNTROWS (
        FILTER (
            ALLSELECTED ( 'Table' ),
            [ID (Text)] = MAX ( 'Table'[ID (Text)] )
                && [Date (Date)] > _lastblank
                && [Date (Date)] < _today
        )
    )

To illustrate the expected outcome, I replaced TODAY() with DATE(2022,2,28).

6.png

Here's the result. For ID 1001, the consecutive working days is 5 and for ID 1002 is 2.

vstephenmsft_1-1679466909849.png

 

Best Regards,

Stephen Tao

 

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

 

Anonymous
Not applicable

Awesome, thanks. 

Really appreciate your help.

 

Chris

Greg_Deckler
Community Champion
Community Champion

@Anonymous Try Cthulhu - Cthulhu - Microsoft Power BI Community



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 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.