Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Always show last monday data

Hi Folks, I have date column in my report based on date column when user selecting any date i want to display  last Monday date on  my report. Can you please help me on DAX. For example today is 23rd nov tuesday when user selecting on 23/11/2021 Tuesday i want to get date last monday(15/11/2021) same as for all. When ever user selecting any date date on middle of day i want to display always last monday.

 

  • HI Anonymous 

     

    to find the last Monday try this:

    Measure =
    VAR _D =
        SELECTEDVALUE ( table[date] ) -- this will return the selected date
    VAR _WN =
        WEEKDAY ( _D, 2 ) -- this will returns a number from 1 to 7 identifying the day of the week of a date
    VAR _WDV = _WN - 1 -- find the variance between Monday and selected date in a week
    VAR _MD = _D - _WDV -- find the Moday date in the selected date week
    RETURN
        _MD - 7
    -- last week Monday date

     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/

     

     

     

1 Reply

  • HI Anonymous 

     

    to find the last Monday try this:

    Measure =
    VAR _D =
        SELECTEDVALUE ( table[date] ) -- this will return the selected date
    VAR _WN =
        WEEKDAY ( _D, 2 ) -- this will returns a number from 1 to 7 identifying the day of the week of a date
    VAR _WDV = _WN - 1 -- find the variance between Monday and selected date in a week
    VAR _MD = _D - _WDV -- find the Moday date in the selected date week
    RETURN
        _MD - 7
    -- last week Monday date

     

     

    If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
    Appreciate your Kudos!!
    LinkedIn: 
    www.linkedin.com/in/vahid-dm/