Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

Is it possible to convert IF + Isblank code to COALESCE

        VAR result = IF ( ISBLANK ( [col1] ), BLANK (), IF ( ISBLANK ( [col2] ), BLANK (), ( DIVIDE ( [col1], [col2] ) - 1 ) ...
  • Adamboer's avatar
    3 years ago

    Here's an example of how the code can be converted using Coalesce:

    VAR result = DIVIDE ( COALESCE ( [col1], BLANK() ), COALESCE ( [col2], BLANK() ) ) - 1 RETURN result

    Coalesce is a function that returns the first non-blank value in a list of expressions. In this case, it's being used to replace the ISBLANK function. The result will be the same as the original code but using a different function.