Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

DAX Switch / IF

Hi,

 

Could I please double check if this is the right syntax to use, or should it be a switch statement?

 

test =

IF(
DATEDIFF(DATEADD(vw1[DateUpdated],-1, MONTH), vw1[CreatedDate], MONTH) = 0
&&
DATEDIFF(DATEADD(vw1[DateUpdated],-1, MONTH), vw1[TargetDate], MONTH) = 0,1,0)
 
Im not sure whether its taking in the second part of the statement.
 
Any help would be greatly appreciated.
 
Thanks
 
Liam


  • Yeah, that syntax is fine, you don't have nested IF statements and not sure a SWITCH statement would make things much cleaner. Whether or not the code works, would need to see sample data to test. 

2 Replies

  • Hi Anonymous ,

     

    The syntax looks right. Can you share if it is not working?

     

    Thanks,

    Pragati

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Yeah, that syntax is fine, you don't have nested IF statements and not sure a SWITCH statement would make things much cleaner. Whether or not the code works, would need to see sample data to test.