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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
huguest
Advocate II
Advocate II

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
v-huizhn-msft
Employee
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)


1.PNG

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])

 

If you have other issues, please feel free to ask.

Best Regards,

Angelia




View solution in original post

12 REPLIES 12
Meha
New Member

How i can exclude Holiday list in same formula?

isamchakur
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
v-huizhn-msft
Employee
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)


1.PNG

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])

 

If you have other issues, please feel free to ask.

Best Regards,

Angelia




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" 2022-04-14_14-12-36.png

@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

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. Issue.png

Can you please help me with some tips?

@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])

 

 

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.  

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)

This really helped me! Thank you very much

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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