cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Lesley1Storey
New Member

Adding Workdays to Dates

Hi, I have a table which shows a created date for when invoices are entered into our system. I need to add workdays onto this date to get our SLA Date. I have a Date Table which has a weekday index included with days 1-5 (saturday and sunday included as day 5). I need to add the workdays onto the created date. The two tables are connected by created date from the Invoices file and Dates from the Date table. Any help would be greatly appreciated.

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @Lesley1Storey ,

 

Don't know if you want a calculated column or a measure but you can do the following.

 

Create a column on your calendar table

Workday = 
SWITCH (
    TRUE ();    
WEEKDAY('Calendar'[Date]) IN { 6 ; 7 }; FALSE (); 
    TRUE ()
)

 

Now add the following measure to your model:

 

Forecasted End Date = 
----------------------------------------------------------
VAR relevantdate =
    SELECTEDVALUE(Invoices[Date]) --this can be replaced by TODAY()
VAR workdaysremain =
    15 --Can be adjusted to be another value
---------------------------------------------------------
/* create a virtual date table only for working days starting from
   the relevant date and only for the workdays remaining */
VAR workingdateTable =
    TOPN (
        workdaysremain;
        CALCULATETABLE (
            'Calendar';
            'Calendar'[Workday] = TRUE ();
            'Calendar'[Date] >= relevantdate
        )
    ) 
---------------------------------------------------------
/* find the maximum date in the virtual table, which will be
   the forecasted end date */
VAR futuredate =
    CALCULATE ( MAX ( 'Calendar'[Date] ); workingdateTable ) 
---------------------------------------------------------
RETURN
    futuredate

 

this was adapted from the post below:

https://www.pbiusergroup.com/communities/community-home/digestviewer/viewthread?MessageKey=a5b04c5c-...

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

1 REPLY 1
MFelix
Super User
Super User

Hi @Lesley1Storey ,

 

Don't know if you want a calculated column or a measure but you can do the following.

 

Create a column on your calendar table

Workday = 
SWITCH (
    TRUE ();    
WEEKDAY('Calendar'[Date]) IN { 6 ; 7 }; FALSE (); 
    TRUE ()
)

 

Now add the following measure to your model:

 

Forecasted End Date = 
----------------------------------------------------------
VAR relevantdate =
    SELECTEDVALUE(Invoices[Date]) --this can be replaced by TODAY()
VAR workdaysremain =
    15 --Can be adjusted to be another value
---------------------------------------------------------
/* create a virtual date table only for working days starting from
   the relevant date and only for the workdays remaining */
VAR workingdateTable =
    TOPN (
        workdaysremain;
        CALCULATETABLE (
            'Calendar';
            'Calendar'[Workday] = TRUE ();
            'Calendar'[Date] >= relevantdate
        )
    ) 
---------------------------------------------------------
/* find the maximum date in the virtual table, which will be
   the forecasted end date */
VAR futuredate =
    CALCULATE ( MAX ( 'Calendar'[Date] ); workingdateTable ) 
---------------------------------------------------------
RETURN
    futuredate

 

this was adapted from the post below:

https://www.pbiusergroup.com/communities/community-home/digestviewer/viewthread?MessageKey=a5b04c5c-...

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.