Search code examples
datepowerbidaxcalculated-columns

Create calculated column to add + work days to a date


I am trying to create a calculated column to add + X work days to a date based on a work day steering table.

In the work day steering table, the bank days are flagged as 0.

What DAX formula should I use to create the calculated column and shift the date + work days further?

Expected Result:
Expected Result

Work day steering table:
Work day steering table


Solution

  • You can use either a Measure or Calculated Column code as given below-

    Measure Code

    add_day_dinamically = 
    MAXX(
        TOPN(
            MIN(your_table_name[transport_lead_time]),
            FILTER(
                all(work_day_steering_table),
                work_day_steering_table[flag] = 1
                && work_day_steering_table[date].[Date] > MIN(your_table_name[date_column_name])
            ),
            work_day_steering_table[date].[Date],
            ASC
        ),
        work_day_steering_table[date].[Date]
    )
    

    Calculated Column Code

    add_day_dinamically_column = 
    MAXX(
        TOPN(
            your_table_name[transport_lead_time],
            FILTER(
                all(work_day_steering_table),
                work_day_steering_table[flag] = 1
                && work_day_steering_table[date].[Date] > your_table_name[date_column_name].[Date]
            ),
            work_day_steering_table[date].[Date],
            ASC
        ),
        work_day_steering_table[date].[Date]
    )
    

    Here is the output-

    enter image description here