Forum Discussion

ysherriff's avatar
ysherriff
Icon for Resolver II rankResolver II
4 years ago
Solved

Nest if in m syntax error

I have the following query in M and wanted to know where my syntax issue is wrong:

 

Original Source = each if [#"Original Source Drill-Down 1"] = "IMPORT"
then "Events" , else if [#"Original Source Drill-Down 1"] = "Salesforce" then "Salesforce", else [Original Source v.1])

 

 

 

 

Thank you for your help.

3 Replies

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    remove the commas.

    To see how powerbi does something like this, use the Column from examples feature.  CAn be quite powerful

    • ysherriff's avatar
      ysherriff
      Icon for Resolver II rankResolver II

      Thanks HotChilli

       

      I will try that later but my focus here is the correct syntax for nested if statement in M.

       

      My original query worked:  = each if [#"Original Source Drill-Down 1"] = "IMPORT"
      then "Events" , else if [#"Original Source Drill-Down 1"] )

       

      but when I tried to add the second parameter that is where the error comes from. Any help would be appreciaited as I am trying to learn query writing.