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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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