Create & Use a Variable in a calculation for a Yes/No dropdown to equal 1.5 or 1

JON C BYERS
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 4, 2025

I am driving myself mad trying to figure out my mistakes. 

  1. I have two Yes / No fields:
    1. issue.customfield_10414
      • For "Adoption"
    2. issue.customfield_10415 
      • For "Retention"
  2. I need to create a variable for both to equal 1.5 if YES or 1 if NO
    • With NO (1) being the default (if possible)
  3. I then need to multiply those variables value against another field
    • issue.customfield_10353

I simply cannot get the syntax right to return any value from the variable. 

  • One of the attempted variable definitions:
    • Name: Retention
      • {{#=}}( 0{{#if(equals(issue.customfield_10415,"Yes"))}}1.5{{/}}{{#if(equals(issue.customfield_10415,"No"))}}1{{/}} ) {{/}}
  • One of the attempted formulae:  
    • {{#=}}{{issue.customfield_10353|0}} * {{issue.Retention}} * {{issue.Adoption}}{{/}}

I am certain the issue is with the variables, but I am cross-eyed at this point. 

Help??

2 answers

0 votes
Bill Sheboy
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
February 4, 2025

Hi @JON C BYERS -- Welcome to the Atlassian Community!

Are your fields single-select, option fields?

If so, please use the value attribute to check them in the condition, and ensure the value exactly matches the case of your field options...or force them to a known case:

{{#if(equals(issue.customfield_10415.value.toLowerCase(), "yes"))}}1.5{{/}}

Can the fields be empty?  If so, ensure you add handling for that case (i.e., what number to use in place of null values).

 

Kind regards,
Bill

0 votes
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 4, 2025

Hello @JON C BYERS 

Welcome to the Atlassian community.

Can you provide screen images showing us your entire rule?

When you create a variable you give it a name. When you then want to use that variable later you do not preface it with issue. That prefix is used only when you want to reference a field in the issue. A variable is not a field in an issue.

Notice that it tells you here exactly how to reference the variable.

Screenshot 2025-02-04 at 3.25.32 PM.png

In addition you can use the Log action right after your Create Variable action to print into the rule execution log file the value of the variable to see if it was set the way you expect.

Screenshot 2025-02-04 at 3.28.23 PM.png

That will help diagnose if the syntax you're using to set the variable is correct. I haven't delved into that syntax yet to evaluate it.

 

Lastly, variables are always stored as Strings. You may need to cast it as a number when you want to use it in a calculation: {{Retention.asNumber}}

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
PREMIUM
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events