Forum Discussion
IF with multiple statements in M language
As the great Ben Gribaudo put it, the only control structures in M are if/then/else. I your case, you probably want if/then/else/if. Basically, multiple conditions outcomes need to be chained together using else if, and conditions can use and/or logic:
if [Widget] = 4 and [Agent] = "Sam" then "Sam's Sale" else if [Widget] = 2 or [Agent].<> "Bob" then "Other" else "No one"
--Nate
- Anonymous5 years agoNot applicable
I'm thinking to something like this:
if <condition>
<begin or other start construct>
<statement 1>
<statement 2>
...
<statement n>
<end or other end construct>
Thanks
- v-kelly-msft5 years agoCommunity Support
Hi Anonymous ,
Could you pls make your requirement detailed?Such as providing some sample data with expected output?
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
- v-kelly-msft5 years agoCommunity Support
Hi Anonymous ,
Is your issue solved now?
Best Regards,
KellyDid I answer your question? Mark my post as a solution!
- Anonymous5 years agoNot applicable
Which other details do you need?
I asked if it is possible to write in M language a such IF with a statement block:
IF <condition>
BEGIN
<statement 1>
<statement 2>
<statement 3>
...
<statement n>
END
In other programming language this is possible (e.g. C, C++, T-SQL, etc.).
Thanks