none
If condition with multiple steps RRS feed

  • Question

  • Hi,

    Is it possible to carry multiple steps within an If statement? the Advanced editor just says else expected.  I've got around 20 steps I need to perform if but the advanced editor just says "else expected" after the first step within the If statement.

    thanks

    Alex

         

       

    Monday, September 14, 2015 4:34 PM

Answers

  • Ah,

    Found an example on how to do this using 

                           

     #"transDate"=if #"Counted Rows" > 0 then 
                 let 

                        {Steps1...}

                 In <LastStep>

    In #"transDate"

    Monday, September 14, 2015 4:43 PM

All replies

  • Ah,

    Found an example on how to do this using 

                           

     #"transDate"=if #"Counted Rows" > 0 then 
                 let 

                        {Steps1...}

                 In <LastStep>

    In #"transDate"

    Monday, September 14, 2015 4:43 PM
  • Alex, the if construct in M must have an else condition, otherwise if the if condition fails, the value of your variable will be indeterminate, resulting in an error. M does not assume any default value if your if condition fails.

    In the example you provide, what is the value of #"transDate" if #"Counted Rows" is 0?

    Monday, September 14, 2015 6:10 PM