Power Query - Function If Null

I have a specific function in Power Query like this:

let Func_Test = (input) =>
    input/1000 + 500
in
    Func_Test

The challange is now, that the input can contain null. If this is the case, then I get an error. How can I avoid this directly in the function?

1

2 Answers

Try

try input/1000 + 500 otherwise null

If I input null into your function, I get null as a response.

However if I don't input anything, the response is an error message :Expression.Error: 0 arguments were passed to a function which expects 1.

For this latter problem, just make the argument optional:

let Func_Test = (optional input) =>
    input/1000 + 500
in
    Func_Test

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Chloe Bennett

Chloe Bennett

Culture, Media & Entertainment Columnist

Chloe Bennett explores the intersection of pop culture, streaming entertainment, digital trends, and contemporary lifestyle. Her weekly commentary reaches thousands of culture enthusiasts.

Share this article
Twitter Facebook Pinterest