Forum Discussion

HenryJS's avatar
HenryJS
Icon for Post Prodigy rankPost Prodigy
6 years ago
Solved

IF date values in last week return 1

Hi all,

 

Please could you advise the DAX for below query

 

IF

  • EITHER: PlacementDate is in the last 7 days
  • OR ExtensionEndDate is in the last 7 days

 

THEN 1

 

ELSE 0

 

 

Thanks,

 

Henry

  • Anonymous's avatar
    Anonymous
    6 years ago

    Should work like this:


    Column =
    IF(
    Table[Placementdate] >=TODAY() - 7 ||
    Table[ExtensionEndDate ] >= TODAY - 7
    1,
    0
    )



  • Anonymous's avatar
    Anonymous
    6 years ago

    Simply remove the equal operator from the second part of the two conditions, the ones that check that date is <=today. Just put inferior to today.

7 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Should work like this:


    Column =
    IF(
    Table[Placementdate] >=TODAY() - 7 ||
    Table[ExtensionEndDate ] >= TODAY - 7
    1,
    0
    )



    • HenryJS's avatar
      HenryJS
      Icon for Post Prodigy rankPost Prodigy

      That only returns values that are both those statements

       

      How do I return values

       

      IF
      Table[Placementdate] >=TODAY() - 7 
       
      OR
       
      Table[ExtensionEndDate ] >= TODAY - 7
      • Anonymous's avatar
        Anonymous
        Not applicable

        The double pipe is equivalent to the OR operator. It should return 1 if either one of the mentioned conditions is true. Are you sure it's interpreting it as an AND condition? It would be very weird