If THEN ELSE in Calculated Fields

Issue #708 resolved
Christoph Ritter created an issue

Hi Fidel,

is there a way to use If Then Else constructs in the calcualed number fields?

Comments (5)

  1. Fidel Castro Armario repo owner

    Yes, you can use ? : conditional operator, which uses the following format:

    <boolean_expression> ? <then_math_expression> : <else_math_expression>.

    Example: Calculated Number Field called "Time to Due Date"

    Captura de pantalla 2017-08-02 a las 10.33.28.png

    The expression used here is:

    {00012} != null ? {00012} - {00057} : null
    

    where {00012} is field code for Due date, and {00057} is field code for Current date and time.

    Here we are using ? : operator for avoiding to do subtraction when Due date is not set.

    You can tell me your exact requirements and I will help you to implement them.

  2. Christoph Ritter reporter

    I would like to Normalize Story Points based on the team working on the Issue.

    If team A is in customfield "team" then 50 * value in customfield "storie points" If team B is in customfield "team" then 25 * value in customfield "storie points"

  3. Fidel Castro Armario repo owner

    You should use an expression like this one:

    %{ttttt} = "Team A" ? 50 * {ppppp} : (%{ttttt} = "Team B" ? 25 * {ppppp} : {ppppp})
    

    Replacing ttttt with field code for field Team, and ppppp with field code for field Story Points.

  4. Log in to comment