Forum Discussion
Add working days to a date
- 9 years ago
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])
If you have other issues, please feel free to ask.
Best Regards,
Angelia
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])
If you have other issues, please feel free to ask.
Best Regards,
Angelia
- Anonymous4 years agoNot 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"
- Yodders9 years agoRegular Visitor
This really helped me! Thank you very much
- tanct8 years agoRegular 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)
- nadirS5 years agoHelper 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.
- Anonymous5 years agoNot 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]) - Anonymous5 years agoNot applicable
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.
Can you please help me with some tips?
- Emanuel5 years agoHelper I
Anonymous 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
- Emanuel4 years agoHelper 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
- Meha_k2 years agoNew Member
How can i exclude Holiday list in above formula?
- Anonymous2 years agoNot applicable
Can you show me how to do this?
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>)