Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
8 years ago
Solved

Adding only workdays to a specific date

Hello   I have a data column i have a number of days column these days can wary from 1-50 days   What i need help figuring out, is how do i subract those days in "workdays" from that date and t...
  • sdjensen's avatar
    sdjensen
    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
        )
    )