Forum Discussion

WilliamAzevedo's avatar
WilliamAzevedo
Advocate II
2 years ago
Solved

New column based in multiple If statements in Power Query

Hello.   I'm trying to create a column based on three date columns, if the first is null, then look for the second and if that is also null look for the third. Here's the example:   M - Início...
  • vicky_'s avatar
    2 years ago

    The very last else if is causing the issue - i think the code there should be

    if [#"N - Início"] <> null then [#"N - Início"] 

    If you're interested, there's the coalesce function in PowerQuery, which might make it a bit easier to read and debug your code:

    https://gorilla.bi/power-query/coalesce/

    So in your case, you can rewrite the if statement as:

    each [#"M - Início"] ?? [#"T - Início"] ?? [#"N - Início"] ?? null