Forum Discussion
Adding only workdays to a specific date
- 8 years ago
Hi,
I created the calculations.
Try having a look at this: https://www.dropbox.com/s/5fareeag77bfc6x/power%20bi%20example.pbix?dl=0&m=
Result:
- 8 years ago
Okay - to assist others with similar challenges I will just make a short description of the solution I created.
First make sure that there is a relationship between the table and the calendar table.
Then in the calendar table create a few columns to create an index for workingdays
IsWorkday = SWITCH( WEEKDAY('Calendar'[Date]); 1; 0; 7; 0;1 ) WorkingDayIndex = RANKX( FILTER( 'Calendar'; 'Calendar'[IsWorkDay] = 1 ); 'Calendar'[Date]; ;ASC )Then in the table that should hold the result I created this calculation that make a simple lookup in the calendar table using the index column created above.
NewDate = VAR DateIdx = CALCULATE( MAX( 'Calendar'[WorkingDayIndex] ); 'Table1'[Date] = RELATED('Calendar'[Date] ) ) VAR NewDateIdx = DateIdx + Table1[Transport days] RETURN CALCULATE( MAX('Calendar'[Date]); FILTER( ALL('Calendar'); 'Calendar'[WorkingDayIndex] = NewDateIdx && 'Calendar'[IsWorkday] = 1 ) )
Made a quick model here for you, hope that helps.
https://www.dropbox.com/s/829noofd84yrr38/power%20bi%20example.pbix?dl=0
Hi,
I created the calculations.
Try having a look at this: https://www.dropbox.com/s/5fareeag77bfc6x/power%20bi%20example.pbix?dl=0&m=
Result:
- Anonymous8 years agoNot applicable
Hey and thank you for the reply
There seems to be something wrong with the calc. When i count the days on the calander it dosent match.
I dont know whats wrong
- sdjensen8 years ago
Solution Sage
Which results is wrong?
In an earlier reply you stated that the result should be 25-04-2017 if the date is 20-04-2017 and transportations days is 16 and that is what I get from my result.
- Anonymous8 years agoNot applicable
I see now whats wrong. the dates i gave you in the example were almost all weekends starter dates. So when i count from the first monday it turns out wrong. But the one from wednesday (onsdag) 5.july is correct.
Sorry the fault is all on my side.
Thank you very mutch for youre help!
- sdjensen8 years ago
Solution Sage
Could you give me the correct results for the demo data then I can have a look at it, but it's easier if I have the wanted result. I have an idea about that is wrong with the calculation, but it's nice to have something to confirm that I make the correct changes.
- Anonymous4 years agoNot applicable
Hi! I have this problem too, but there are specific # of days to add depending on the country's requirement. How to add # of days per country?