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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
scabbyabbey
Regular Visitor

Number of working days between two dates but using today if no resolved date

I'm using the following to calculate the age of an incident using working days only. It works perfectly for incidents that have a resolved date, but for incidents that don't have a resolved date it is counting non-working days as well. 

 

I have a date table that shows Monday to Friday as 1s for working days, and Saturdays and Sundays as 0. 

 

Can someone point out what wrong here? I'm an absolute novice and pieced this together from other solutions I'd found. 

 

Thank you.

 

INC Age = IF(OR(ISBLANK('SN'[Created.Date1]),ISBLANK('SN'[Resolved.Date1])),
DATEDIFF('SN'[Created.Date1],TODAY(),DAY),
IF(OR
('SN'[Resolved.Date1] < 'SN'[Created.Date1],'SN'[Created.Date1] > 'SN'[Resolved.Date1]),
-1 *CALCULATE(COUNT('DateTable'[IsWorkDay]),FILTER('DateTable','DateTable'[Date] < SN[Created.Date1] && 'DateTable'[Date]>=SN[Resolved.Date1] && 'DateTable'[IsWorkDay] = 1)) + 0,
CALCULATE(COUNT('DateTable'[IsWorkDay]),FILTER('DateTable','DateTable'[Date] >= SN[Created.Date1] && 'DateTable'[Date]<'SN'[Resolved.Date1] && 'DateTable'[IsWorkDay] = 1)))) + 0

1 ACCEPTED SOLUTION
v-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @scabbyabbey,

 

Please try:

INC Age =
IF (
    OR ( ISBLANK ( 'SN'[Created.Date1] ), ISBLANK ( 'SN'[Resolved.Date1] ) ),
    CALCULATE (
        COUNT ( 'DateTable'[IsWorkDay] ),
        FILTER (
            'DateTable',
            'DateTable'[Date] >= SN[Created.Date1]
                && 'DateTable'[Date] < TODAY ()
                && 'DateTable'[IsWorkDay] = 1
        )
    ),
    IF (
        OR (
            'SN'[Resolved.Date1] < 'SN'[Created.Date1],
            'SN'[Created.Date1] > 'SN'[Resolved.Date1]
        ),
        -1
            * CALCULATE (
                COUNT ( 'DateTable'[IsWorkDay] ),
                FILTER (
                    'DateTable',
                    'DateTable'[Date] < SN[Created.Date1]
                        && 'DateTable'[Date] >= SN[Resolved.Date1]
                        && 'DateTable'[IsWorkDay] = 1
                )
            )
            + 0,
        CALCULATE (
            COUNT ( 'DateTable'[IsWorkDay] ),
            FILTER (
                'DateTable',
                'DateTable'[Date] >= SN[Created.Date1]
                    && 'DateTable'[Date] < 'SN'[Resolved.Date1]
                    && 'DateTable'[IsWorkDay] = 1
            )
        )
    )
)
    + 0

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
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-yulgu-msft
Microsoft Employee
Microsoft Employee

Hi @scabbyabbey,

 

Please try:

INC Age =
IF (
    OR ( ISBLANK ( 'SN'[Created.Date1] ), ISBLANK ( 'SN'[Resolved.Date1] ) ),
    CALCULATE (
        COUNT ( 'DateTable'[IsWorkDay] ),
        FILTER (
            'DateTable',
            'DateTable'[Date] >= SN[Created.Date1]
                && 'DateTable'[Date] < TODAY ()
                && 'DateTable'[IsWorkDay] = 1
        )
    ),
    IF (
        OR (
            'SN'[Resolved.Date1] < 'SN'[Created.Date1],
            'SN'[Created.Date1] > 'SN'[Resolved.Date1]
        ),
        -1
            * CALCULATE (
                COUNT ( 'DateTable'[IsWorkDay] ),
                FILTER (
                    'DateTable',
                    'DateTable'[Date] < SN[Created.Date1]
                        && 'DateTable'[Date] >= SN[Resolved.Date1]
                        && 'DateTable'[IsWorkDay] = 1
                )
            )
            + 0,
        CALCULATE (
            COUNT ( 'DateTable'[IsWorkDay] ),
            FILTER (
                'DateTable',
                'DateTable'[Date] >= SN[Created.Date1]
                    && 'DateTable'[Date] < 'SN'[Resolved.Date1]
                    && 'DateTable'[IsWorkDay] = 1
            )
        )
    )
)
    + 0

 

Best regards,

Yuliana Gu

Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you Yuliana, this worked!

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors