Skip to main content
Skip table of contents

Expr Language - Local Variables

Local variables are helpful when an expression needs to be used in the same formula several times. For example:

CODE
IF time_spent + remaining_estimate > 0 :
   time_spent / (time_spent + remaining_estimate)

You can see that in this formula we are using "time_spent + remaining_estimate" twice – once when we check that it's not zero (so we don't divide by zero) and again when we divide by it.

Instead of repeating the expression every time, we can rewrite this formula using the WITH construct:

CODE
WITH total_time = time_spent + remaining_estimate :
  IF total_time > 0 :
     time_spent / total_time

You can define multiple local variables in succession. You can also use previously defined local variables when defining additional local variables. For example:

CODE
WITH total_time = time_spent + remaining_estimate :
WITH progress = (IF total_time > 0 : time_spent / total_time) :
  IF(progress > 0.5, "Great Progress!", progress > 0.2, "Good Progress", "Needs Progress!")

Note the position of the colon (":") – it must be present where each local variable definition ends.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.