Forum Discussion

rschaudhr's avatar
rschaudhr
Icon for Resolver II rankResolver II
5 years ago
Solved

In Calculated Column show the first Wednesday of the current month as default

I have a date column. I want to create another calculated date column where whenever it shows the first Wednesday in the current month and it will say "Default Day" otherwise it will show date from t...
  • v-cazheng-msft's avatar
    5 years ago

    Hi, rschaudhr 

    You can create a Calculated column as following.

     

    Default Date =

    VAR cur_day =

        NOW ()

    VAR first_wes =

        CALCULATE (

            SELECTEDVALUE ( 'SQL Results (3)'[DATE_] ),

            FILTER (

                ALL ( 'SQL Results (3)'[DATE_] ),

                YEAR ( 'SQL Results (3)'[DATE_] ) = YEAR ( cur_day )

                    && MONTH ( 'SQL Results (3)'[DATE_] ) = MONTH ( cur_day )

                    && DAY ( [DATE_] ) >= 1

                    && DAY ( [DATE_] ) <= 7

                    && WEEKDAY ( [DATE_], 3 ) = 2

            )

        )

    RETURN

        CONVERT (

            IF (

                'SQL Results (3)'[DATE_] = first_wes,

                "Default Day",

                'SQL Results (3)'[DATE_]

            ),

            STRING

        )

     

    The result looks like this:

     

    Here is the sample.

     

    Best Regards,

    Caiyun Zheng

     

    Is that the answer you're looking for? If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.