Forum Discussion

Puja's avatar
Puja
Icon for Helper III rankHelper III
3 years ago
Solved

Get only weekdays (exclude weekends) in measure

Hello all,

Is there a way to get  only weekdays (exclude weekends) for the next  6 months based on today's date in measure

 

Ex:Today() + 180 days and exclude weekends.

 

 

TIA

 

 

  • Hi Puja Below is code for creation of calculated tables with dates.

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

     

    Weekdays_Table =
    //create calculated table with weekdays 180 from today
    //WEEKDAY function with values 2 means days Numbers 1 (Monday) through 7 (Sunday), so 6 and 7 are Saturday and Sunday
    SELECTCOLUMNS (
        FILTER (
            CALENDAR ( TODAY(), TODAY() + 180 ),
            WEEKDAY ( [Date], 2 ) < 6
        ),
        "WeekdayDate", [Date]
    )

3 Replies

  • some_bih's avatar
    some_bih
    Icon for Community Champion rankCommunity Champion

    Hi Puja for measure one of approach is as shown below:

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

     

    #WeekdaysNextSixMonths =
    //calculation of weekdays 180 from today
    VAR _start_date = TODAY() // start date
    VAR _end_date = _start_date + 180 // calculate 180 from today
    VAR NumDays = _end_date - _start_date + 1
    VAR _Result =
        SUMX(
            GENERATESERIES(_start_date, _end_date, 1),
            IF(
                WEEKDAY([Value]) <> 1 && WEEKDAY([Value]) <> 7,
                1,
                0
            )
        )
    //WEEKDAY with values 1 and 7 means Saturday and Sunday is excluded
    RETURN
        _Result

     

    • Puja's avatar
      Puja
      Icon for Helper III rankHelper III

      Hi some_bih ,

      Thank you . I need to get DATES  and not  number (129). Sorry I was not clear in my request. 

      Like below exclude weekends.

      7/11/2023
      7/11/2023
      7/11/2023
      7/11/2023
      7/11/2023
      7/11/2023
      7/12/2023
      7/12/2023
      7/12/2023
      7/12/2023
      7/12/2023
      7/12/2023
      7/13/2023
      7/13/2023
      7/13/2023
      7/13/2023
      7/13/2023
      7/13/2023
      7/14/2023
      7/14/2023
      7/14/2023
      7/14/2023
      7/14/2023
      7/14/2023
      7/17/2023
      7/17/2023
      7/17/2023
      7/17/2023
      7/17/2023
      7/17/2023
      7/18/2023
      7/18/2023
      7/18/2023
      7/18/2023
      7/18/2023
      7/18/2023
      7/19/2023
      7/19/2023
      7/19/2023
      7/19/2023
      7/19/2023

       

  • some_bih's avatar
    some_bih
    Icon for Community Champion rankCommunity Champion

    Hi Puja Below is code for creation of calculated tables with dates.

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

     

    Weekdays_Table =
    //create calculated table with weekdays 180 from today
    //WEEKDAY function with values 2 means days Numbers 1 (Monday) through 7 (Sunday), so 6 and 7 are Saturday and Sunday
    SELECTCOLUMNS (
        FILTER (
            CALENDAR ( TODAY(), TODAY() + 180 ),
            WEEKDAY ( [Date], 2 ) < 6
        ),
        "WeekdayDate", [Date]
    )