Is there a "null' function?

Hi, is there a "null’ function? Eg if x=y then null. There is a big difference between zero and null when it comes to computing averages etc. Thanks!

Hi Ian, yes there is! We have a helper variable none for that in Causal. Also make sure to not forget the else at the end of your if-statement:
image

Hi @lorenz_causal , could you please clarify the none helper variable?

I started out using IF x = none then ... else ... but then realized it behaves oddly.

I then switched to IF is_empty(x) then ... else ... which seems to work more consitently with what I’d expect.

Is there a recommedation when none may be used and when not ?

Thank you & Best Regards
Fabian

1 Like

Hey Fabian, that’s a great question!
is_empty(X) and X = none are slightly different.

  • is_empty(X) checks if the variable doesn’t have an expression - no matter what the value is
  • X = none checks if the value of the variable is none. This can either be the case because the variable doesn’t have an expression and the “Empty Value” is set to none, or because it has an expression which evaluates to none (an error is also considered to have the value none). You can change if an empty period of a variable has the value 0 or none in the context menu:
    image

Here is an example of the differences between is_empty(X) and X = none:


  • is_empty(X) only evaluates to 1 in Jan - because X doesn’t have an expression in Jan.
  • X = none evaluates to 1 in Mar and Apr, because the value of the variable is none (in Mar it is an error because of the division by 0). If the Empty Value of X was set to None, it would also evaluate to 1 in Jan.
2 Likes