cancel
Showing results 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

## Add working days to a date

Hello, I am fairly new to Power BI and to this forum (first post).  I need to add a column that adds a fixed number (e.g. 15) of working days to a date that is already in my table.  In Excel, I use =WORKDAY([Date],15,[Holidays]), but I cannot figure out how to get the equivalent output in Power BI.  I am able to add a certain number of days (using Date.AddDays([Date], 15), but would really need to add working days.  Any help would be appreciated.

hu9uest.

1 ACCEPTED SOLUTION
Employee

Hi @huguest,

After research and test, there is no a function used to achieve same requirement in Power BI. You can follow the following to solutions.

1.You can calculated them in Excel, then load the data to PowerBI.

2. Create a Canlendar table.  The start_date is your min(facttable[date]), and end_date your max(facttable[date]).

CALENDAR(<start_date>, <end_date>)

In Calendar table, create calculated column to display the day if it is work day, rank all working days, get the result based on calculated columns. For example, I add futher 10 working days.

```Identify = IF(OR(WEEKDAY(Canlendar[Date])=1, WEEKDAY(Canlendar[Date].[Date])=7),0,1)

Rank1 = RANKX(FILTER(Canlendar,Canlendar[Identify]=1),Canlendar[Date],,ASC)

Add 10 woring days = LOOKUPVALUE(Canlendar[Date],Canlendar[Identify],1,Canlendar[Rank1],Canlendar[Rank1]+10)```

Create a relationship batween Calendar and your fact table.  Use the related function to get the result in fact table.

`Result=RELATED(Calendar[Add 10 woring days])`

Best Regards,

Angelia

12 REPLIES 12
New Member

How i can exclude Holiday list in same formula?

Frequent Visitor
Hello, I tried something that worked well to if you do not consider the Hollidays during the week: DayofWeek = Date.DayOfWeek([Date] 3WorkDaysBefore = if [DayofWeek ]=1 then Date.AddDays([Date],-5) else if [DayofWeek ]=2 then Date.AddDays([Date],-5) else if [DayofWeek ]=3 then Date.AddDays([Date],-5) else if [DayofWeek ]=4 then Date.AddDays([Date],-3) else if [DayofWeek ]=5 then Date.AddDays([Date],-3) else null
Employee

Hi @huguest,

After research and test, there is no a function used to achieve same requirement in Power BI. You can follow the following to solutions.

1.You can calculated them in Excel, then load the data to PowerBI.

2. Create a Canlendar table.  The start_date is your min(facttable[date]), and end_date your max(facttable[date]).

CALENDAR(<start_date>, <end_date>)

In Calendar table, create calculated column to display the day if it is work day, rank all working days, get the result based on calculated columns. For example, I add futher 10 working days.

```Identify = IF(OR(WEEKDAY(Canlendar[Date])=1, WEEKDAY(Canlendar[Date].[Date])=7),0,1)

Rank1 = RANKX(FILTER(Canlendar,Canlendar[Identify]=1),Canlendar[Date],,ASC)

Add 10 woring days = LOOKUPVALUE(Canlendar[Date],Canlendar[Identify],1,Canlendar[Rank1],Canlendar[Rank1]+10)```

Create a relationship batween Calendar and your fact table.  Use the related function to get the result in fact table.

`Result=RELATED(Calendar[Add 10 woring days])`

Best Regards,

Angelia

New Member

How can i exclude Holiday list in above formula?

Anonymous
Not applicable

I know this is a bit of a dated post but when I used the above formulas I am getting blanks for "add working days"

Helper I

@v-huizhn-msft Is it possible to add also the time for the business days? Like I have the date 1-Oct-2021 9:39 PM and I need to add 5 business days to it but the result will look like 8-Oct-2021 12:00 AM. Instead I need the time to show the actual end of business day, like 6pm for example. Is it possible based on your solution?

Thanks

Emanuel

New Member

Hi,

I am facing some challenges: the formula for adding 'n' days doesn't show a future date or the date which is the last row in the 'Date' column.

If the last date 24-JUN-2021, then adding 5 days should show 1-JUL-2021, but the last entry which I am getting in 'Add 5 working days' column is 17-JUN-2021.

Attaching the screenshot for your reference.

Helper I

@anchitsahay I had the same problem and is related to the end date you have configured in  you calendar. Add a year to your end date calendar and this is fixed.
Hope this helps

Anonymous
Not applicable

I have done in the same way and given relation between the calendar and fact table but then also when i write releated i am getting blank value. i am pasting my formula in the below. kindly help me where i am doing the mistake.

New Target Date = if(AND('otd France_DB'[product_source_type]=1,or(or(or(or('otd France_DB'[ARC_HC_Tint_CEF_Mapping]=2,'otd France_DB'[ARC_HC_Tint_CEF_Mapping]=9),'otd France_DB'[ARC_HC_Tint_CEF_Mapping]=10),'otd France_DB'[ARC_HC_Tint_CEF_Mapping]=11),'otd France_DB'[ARC_HC_Tint_CEF_Mapping]=6)),RELATED('Calendar'[Add 5 woring day]),

if(AND('otd France_DB'[product_source_type]=1,or(or('otd France_DB'[ARC_HC_Tint_CEF_Mapping]=3,'otd France_DB'[ARC_HC_Tint_CEF_Mapping]=4),'otd France_DB'[ARC_HC_Tint_CEF_Mapping]=5)),related('Calendar'[Add 4 woring day])

Helper I

is there a way i can do a reversal on the same thing that you explained above - I have a date table and i am able to calculate working days.(0s for weekends and 1's for Weekdays). I need to add 5 days to my start date and and pick the appropriate working date from the date table so that it gives me an "Expected Completion Date" that takes account of weekends.

Regular Visitor

Hi Angelia,

Could you elaborate more on the below function (ASC?) or share me the image of the "rank 1" the full complete dax code (as what you did for Add 10 woring days ) because I stucked on this step,thanks.

Rank1 = RANKX(FILTER(Canlendar,Canlendar[Identify]=1),Canlendar[Date],,ASC)

Regular Visitor

This really helped me! Thank you very much

Announcements

#### Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

#### Power BI Monthly Update - June 2024

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

#### New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors