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
cottrera
Post Prodigy
Post Prodigy

Working Days between two dates

Hi

 

I have a dates table

cottrera_0-1655379088574.png

 

 

And a facts table  

Reference NumberDate LoggedTarget DaysTarget Date
2478501/01/20195DAX Required
3437501/01/20191DAX Required
6132201/01/201915DAX Required
5306701/01/201915DAX Required
4671902/01/201915DAX Required
3676802/01/20191DAX Required
5850002/01/201960DAX Required
6141703/01/201960DAX Required
4711703/01/20195DAX Required

 

I would like a DAXfunction that adds the Taget Days to the Date Logged but calculates this in working days.

 

For example the fist line of the facts table , the logged date is 01/01/2019 which is a Friday so by adding due days 5 would make the due date 06/01/2019.  This is not what I require as I need to include only working days.  The correct due date would be 08/01/2019.

 

I have a date table which has a column called is_workignday.

 

thank you

RIchard

 

 

Richard

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

@cottrera , you can do this by adding a Calculated Column to your facts table:

Target Date = 
    MAXX(
        TOPN(
            'facts'[Target Days]
            , FILTER(
                'Dates'
                , 'Dates'[Date] >= 'facts'[Date Logged]
                && 'Dates'[is_workday] = 1
            )
        )
        ,'Dates'[Date]
    )

 

If you want to create a measure first to see how it will look, teh measure syntax is slightly different:

Target Date (measure) = 
    VAR vLogged = SELECTEDVALUE('facts'[Date Logged])
    VAR VDays = SELECTEDVALUE('facts'[Target Days])
    RETURN
        MAXX(
            TOPN(
                vDays
                , FILTER(
                    'Dates'
                    , 'Dates'[Date] >= vLogged
                    && 'Dates'[is_workday] = 1
                )
            )
            ,'Dates'[Date]
        )

View solution in original post

2 REPLIES 2
cottrera
Post Prodigy
Post Prodigy

Thank you for your quick reponse you dax functions work fine 😀

Anonymous
Not applicable

@cottrera , you can do this by adding a Calculated Column to your facts table:

Target Date = 
    MAXX(
        TOPN(
            'facts'[Target Days]
            , FILTER(
                'Dates'
                , 'Dates'[Date] >= 'facts'[Date Logged]
                && 'Dates'[is_workday] = 1
            )
        )
        ,'Dates'[Date]
    )

 

If you want to create a measure first to see how it will look, teh measure syntax is slightly different:

Target Date (measure) = 
    VAR vLogged = SELECTEDVALUE('facts'[Date Logged])
    VAR VDays = SELECTEDVALUE('facts'[Target Days])
    RETURN
        MAXX(
            TOPN(
                vDays
                , FILTER(
                    'Dates'
                    , 'Dates'[Date] >= vLogged
                    && 'Dates'[is_workday] = 1
                )
            )
            ,'Dates'[Date]
        )

Helpful resources

Announcements
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!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

Top Solution Authors