Forum Discussion

Jay2022's avatar
Jay2022
Icon for Helper IV rankHelper IV
1 year ago
Solved

if and statements with date columns if null

The first if statement is working the rest are coming up as erors where am i going wrong ?

 

if [#"Date 1"] = null then [#"Date 2"]

else if [#"Date 1"] = null and [#"Date 2"] = null

then [#"Date 3"] else 0

 

Any help greatly appreciated 

  • Hi, 
    The order of condition is not appropriate, in the first condition if [#"Date 1"] = null  is true, it result in  [#"Date 2"] which might be null also, so revise the formula as follow

    if [#"Date 1"] = null and [#"Date 2"] = null

    then [#"Date 3"] else if [#"Date 1"] = null then [#"Date 2"]

    else 0



  • You can also use the following magical writing method:

    [#"Date 1"] ?? [#"Date 2"] ?? [#"Date 3"] ?? 0

3 Replies

  • Hi, 
    The order of condition is not appropriate, in the first condition if [#"Date 1"] = null  is true, it result in  [#"Date 2"] which might be null also, so revise the formula as follow

    if [#"Date 1"] = null and [#"Date 2"] = null

    then [#"Date 3"] else if [#"Date 1"] = null then [#"Date 2"]

    else 0



  • You can also use the following magical writing method:

    [#"Date 1"] ?? [#"Date 2"] ?? [#"Date 3"] ?? 0