Forum Discussion

Boycie92's avatar
Boycie92
Resolver I
5 years ago
Solved

Date Feild Conditions

Hi   I am hoping someone can help.   I have a data table with a date field. I need the following fields created using DAX or Power Query, but I am struggling with the syntax.   TodaysDate = If ...
  • amitchandak's avatar
    5 years ago

    Boycie92 , refer these new columns

     

    Is Today = if('Date'[Date]=TODAY(),1,0)

     

    This week = if([Date] >= 'today()+-1*WEEKDAY(today() ,2)+1 && [Date] <= today()+ 5-1*WEEKDAY(today(),2) ,1,0)

     

    Month Type = Switch( True(),
    Date([Date])= eomonth(Today(),0),1 ,
    0
    )

     

    las6 6Months Type = Switch( True(),
    ([Date]) >= eomonth(Today(),-6) && Date([Date])<= eomonth(Today(),0) ,1 ,
    0
    )

     

    Year Type = Switch( True(),
    year([Date])= year(Today()),1,
    0
    )

     

    Refer : https://www.youtube.com/watch?v=hfn05preQYA

  • v-robertq-msft's avatar
    v-robertq-msft
    5 years ago

    Hi, Boycie92 

    According to your follow-up, it seems like you want to create the fields based on the filtered date between April 2020 to Match 2021. I think you can first create a filtered table like this:

    Filtered Date=
    Filter(‘Date’,[Date]>=Date(2020,4,1)&& [Date]<Date(2021,3,1)

    Then you can create the calculated columns based on the DAX formulas posted by amitchandak.

    And you can get what you want.

    If you still have a problem, you can post some sample data(without sensitive data) and your expected result.

    How to Get Your Question Answered Quickly 

     

    Best Regards,

    Community Support Team _Robert Qin

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