Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

IF/AND statement in query

Hi,   I want to create the count in query but this show syntax error. Please help.   IF(MONTH([Created Date])=MONTH([Restoration Date]) && YEAR([Created Date])=YEAR([Restoration Date])),1,0)  ...
  • amitchandak's avatar
    amitchandak
    5 years ago

    Anonymous , The syntax you have give is DAX and you trying in power query.

     

    DAX

    IF(MONTH([Created Date])=MONTH([Restoration Date]) && YEAR([Created Date])=YEAR([Restoration Date]),1,0)

     

    Power Query /M

     

    if Date.Month([Created Date])=Date.Month([Restoration Date]) and Date.Year([Created Date])=Date.Year([Restoration Date]) then 1 else 0

    if Date.Month([Created Date])=Date.Month([Restoration Date]) && Date.Year([Created Date])=Date.Year([Restoration Date]) then 1 else 0

  • Ashish_Mathur's avatar
    Ashish_Mathur
    5 years ago

    Hi,

    In the Query Editor, try this

    =if Date.Month([Created Date])=Date.Month([Restoration Date]) and Date.Year([Created Date])=Date.Year([Restoration Date]) then 1 else 0

    Hope this helps.