Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
When am I supposed to use which of both statements?
I was wrongly assuming that I can use both interexchangeably.
Thanks in advance for a clarification.
On a separate note: What's the correct terminology here?
I am borrowing "statement" from Python terminology, I am not sure though if the same jargon applies here (I am new to coding, Python was the first language I learned, M is becoming my second).
Solved! Go to Solution.
To the best of my knowledge, M does not use "otherwise", here is a good article on IF statement in M:
https://www.excelguru.ca/blog/2014/08/27/the-if-function-in-power-query/
and here is a great article by @ImkeF on an M switch statement:
http://www.thebiccountant.com/
Yes! & to sum Gregs @Greg_Deckler hints up:
1) else goes with if for conditions
2) otherwise goes with try for error handling
Cheers, Imke
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
Hi @RafaelKnuth,
There a good post about it:
https://community.powerbi.com/t5/Community-Blog/The-Languages-of-Power-BI/ba-p/69104
Ricardo
To the best of my knowledge, M does not use "otherwise", here is a good article on IF statement in M:
https://www.excelguru.ca/blog/2014/08/27/the-if-function-in-power-query/
and here is a great article by @ImkeF on an M switch statement:
http://www.thebiccountant.com/
Looked up a few solutions and was able to use try .... otherwise in M code just now, saw your answer and wanted to encourage you to to try it!
I ran into the "else" and "otherwise" statements in Miguel Escobar's book "M is for (Data) Monkey". Thanks for sharing!
Also, if you want THE definitive guide to M you can download the language specification here:
https://msdn.microsoft.com/en-us/library/mt807488.aspx
It's a bit dry but you'll learn a lot.
Now that I am thinking about it, I believe you actually do use "otherwise" in "try" statements, so something like:
let Source = Web.Contents("http://localhost:5001/foo"), Parsed = try Json.Document(Source) otherwise error "Update credentials please" in Parsed
Yes! & to sum Gregs @Greg_Deckler hints up:
1) else goes with if for conditions
2) otherwise goes with try for error handling
Cheers, Imke
Imke Feldmann (The BIccountant)
If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!
How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries
User | Count |
---|---|
139 | |
113 | |
103 | |
73 | |
63 |
User | Count |
---|---|
136 | |
125 | |
107 | |
70 | |
61 |