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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
danialsj
Frequent Visitor

Add days to customer calendar

I have a custom calendar table which excludes weekends and certain holidays. I want to create a custom column in which I can add X number of days to a date while ignoring the weekends and the holidays. How can I achieve this? 

 

Below is a rough dataset

DateDaysToAddCalculatedCol
26-Oct229-Oct

 

 

DateHolidays
26-OctNo
27-OctYes
28-OctNo
29-OctNo
1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@danialsj 

You can try the following calculated column, you can replace _Days variable value with a column value if you need also 365 in the calculation can be extended if necessary.

DaysToAdd = 
VAR __Days = 2
VAR __CURRENTDATE = Data[Date]
VAR __HOLIDAYS = CALCULATETABLE( VALUES(Holiday[Date]) , Holiday[Holidays] = "Yes" , Holiday[Date] >= __CURRENTDATE , Holiday[Date] <= __CURRENTDATE + 365   ) 
VAR __RESULT = 
    MAXX(
        TOPN( 
            __Days+1,
            FILTER(
                CALENDAR( __CURRENTDATE  , __CURRENTDATE + 365 ),
                NOT [Date] IN  __HOLIDAYS
            ),
            [Date],ASC
        ),
        [Date]
    )
RETURN
__RESULT

 

Fowmy_0-1635767369974.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

2 REPLIES 2
Fowmy
Super User
Super User

@danialsj 

You can try the following calculated column, you can replace _Days variable value with a column value if you need also 365 in the calculation can be extended if necessary.

DaysToAdd = 
VAR __Days = 2
VAR __CURRENTDATE = Data[Date]
VAR __HOLIDAYS = CALCULATETABLE( VALUES(Holiday[Date]) , Holiday[Holidays] = "Yes" , Holiday[Date] >= __CURRENTDATE , Holiday[Date] <= __CURRENTDATE + 365   ) 
VAR __RESULT = 
    MAXX(
        TOPN( 
            __Days+1,
            FILTER(
                CALENDAR( __CURRENTDATE  , __CURRENTDATE + 365 ),
                NOT [Date] IN  __HOLIDAYS
            ),
            [Date],ASC
        ),
        [Date]
    )
RETURN
__RESULT

 

Fowmy_0-1635767369974.png

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

amitchandak
Super User
Super User

@danialsj , I have a blog on how to deal with this, see if that can help

Traveling Across Workdays - What is next/previous Working day
https://community.powerbi.com/t5/Community-Blog/Travelling-Across-Workdays-Decoding-Date-and-Calenda...

Helpful resources

Announcements
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.