Forum Discussion
Error Handling (like Try-Catch in SQL)
- 4 years ago
Hi Anonymous ,
To do this at the code level in M, you use the try...otherwise structure e.g.
try [Value] / 10 otherwise nullTo do this at the whole query level you can try these methods:
Ensure columns always present:
Handle source qury errors:
https://blog.crossjoin.co.uk/2014/09/18/handling-data-source-errors-in-power-query/
Make sure to read the comments after each of these blogs carefully, as other users add crucial amendments to the original code.
Pete
Hi Anonymous ,
To do this at the code level in M, you use the try...otherwise structure e.g.
try [Value] / 10 otherwise null
To do this at the whole query level you can try these methods:
Ensure columns always present:
Handle source qury errors:
https://blog.crossjoin.co.uk/2014/09/18/handling-data-source-errors-in-power-query/
Make sure to read the comments after each of these blogs carefully, as other users add crucial amendments to the original code.
Pete
- AlexisOlson4 years ago
Super User
Ben Gribaudo also has a valuable article on error handling.
https://bengribaudo.com/blog/2020/01/15/4883/power-query-m-primer-part-15-error-handling