Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

How to get a specific date

I have a column I need to filter. As of Now I have it like this:

 

BeforeToday_MI = IF(Query_Util[MoveInDate].[Date] < TODAY(), True, False) 
 
It returns True if MoveInDate column has dates prior to today. However, I want the function to return true if the date is before Today AND the day is not Saturday or Sunday; in other words, the date belong to a weekday and not a weekend.

 

I tried this but it's giving me error: 

BeforeToday_MI = IF(Query_Util[MoveInDate].[Date] < TODAY() && VALUE(Query_Util[MoveInDate].[Day]) <> "Saturday", True, False)
  • Anonymous ,

     

    BeforeToday_MI = IF( datevalues(Query_Util[MoveInDate]) < TODAY() && weekday(Query_Util[MoveInDate],2) <6 , True, False) 

3 Replies

  • Anonymous ,

     

    BeforeToday_MI = IF( datevalues(Query_Util[MoveInDate]) < TODAY() && weekday(Query_Util[MoveInDate],2) <6 , True, False) 

    • Anonymous's avatar
      Anonymous
      Not applicable

      What if I want to get the days that are not Saturday or Sunday?

       

      (My bad; I forgot to include that specification before. I need work days. Your code works perfectly; I just need to act the condition of filtering out Sunday as well.)

      • v-chenwuz-msft's avatar
        v-chenwuz-msft
        Icon for Community Support rankCommunity Support

        Hi Anonymous ,

         

        Did you get your problem solved? If it was solved, please mark it as a solution so that more people can find it. If not, refer to the following.

         

        weekday(Query_Util[MoveInDate],2) return result follow the following rule.

        week begins on Monday (1) and ends on Sunday (7).

         

        If you only want filter out  sunday, then weekday(Query_Util[MoveInDate],2) <7. Or enter the day you want like this:

        weekday(Query_Util[MoveInDate],2) = 1 &&

        weekday(Query_Util[MoveInDate],2) = 2 &&

        weekday(Query_Util[MoveInDate],2) = 3 &&

        weekday(Query_Util[MoveInDate],2) = 4

         

        More detail you can refer this function.

        WEEKDAY function (DAX) - DAX | Microsoft Docs

         

        Best Regards

        Community Support Team _ chenwu zhu

         

        If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.