Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to sum quantitative values from multiple custom fields?

Frank
Contributor
July 3, 2023

Problem: I have multiple custom fields in a company-managed project that I am looking to:

  1. take the qualitative value from a drop-down menu of options
  2. translate that value to a quantitative value
  3. sum those values and assign that value to another custom field

 

Context:

The 2 custom fields that I have are both drop downs and contain these values:

  • T-shirt size (custom field): small, medium, large, extra large (Drop down values)
  • T-shirt Color (custom field): red, green, blue (Drop down values)

 

Intended End Goal Solution:

What I would like to do, using JIRA's automation if possible, is translate those qualitative values to quantitative values.

  • So, if I were to choose "medium" for T-shirt size, I would like to translate that to a value of 2
  • And if I were to choose "red" for T-shirt Color, I would like to translate that to a value of 1
  • Then I would like to add those two values together, 2+1=3, and assign that value of 3 to a new custom field of T-shirt Estimation

 

Does anyone know how to solve the problem above with the context that I have given via JIRA automation and smart values?

1 answer

2 votes
Trudy Claspill
Community Champion
July 3, 2023

Hello @Frank 

I have not used it myself, but I have seen other posts similar to this where the suggestion was to use the Lookup Table action 

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.
July 3, 2023

Hi @Frank 

Adding to Trudy's answer: once you have stored your conversions in the Lookup Tables, you could use those in math operations to calculate the result: https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/

Kind regards,
Bill

Like # people like this
Frank
Contributor
July 3, 2023

@Bill Sheboy @Trudy Claspill 

So the automation would look something like this? Having a hard time figuring out how this should break out:

  1. When: manually triggered (Will change in the future)
  2. Then: Create the lookup table for the custom field "T-shirt size"with the drop-down options mapping to the numeric values
    • (key) Small: (value) 1
    • Medium:2
    • Large:3
    • etc
  3. If: {{LookupTable.get("Medium")}} == {{T-shirt size.description}}
  4. Then: T-shirt Estimation += {{LookupTable.get("Medium")}}
  5. Do the same thing above for each custom field, in this case I would need to do it for T-shirt Color also

 

So basically, you would:

  1. create the lookup table
  2. map the T-shirt sizes to a numeric value
  3. check and see if the custom field value == one of the lookup table values
  4. if so, add it to the final value "T-shirt Estimation".
  5. Do it all over again for T-shirt color

 


 

Also, I have 10 different custom fields that I would want to do this for, so I'm thinking I should have one automation per custom field given that the max values that you can hold in a lookup table is only 20 and my 10 custom fields have 35 options between them all. Thoughts on that?

Like John Funk likes this
Trudy Claspill
Community Champion
July 3, 2023

You haven't quite got it.

1. You would create a separate Lookup Table for each custom field. Each table would have a mapping of the values for just one of your custom fields.

2. Each Lookup Table you create gets a name. Let us say you name the T-shirt Size table "tshirtSize". Then to get the value for one of the keys in that table you would use the smart value:

{{tshirtSize.get(issue.T-shirt Size.name)}}

You could use that in an Edit action to update the value of the T-shirt Estimation field. To add the retrieved value to the value already in the T-shirt Estimation field you would use (from the Math Expressions Smart Values documentation)

{{issue.T-shirt Estimation.plus(tshirtSize.get(issue.T-shirt Size.name))}}

 

I haven't actually created my own custom fields and tried this out, but that is how I think you would do it, based on the documentation.

Like # people like this
Trudy Claspill
Community Champion
July 3, 2023

Just did some experimenting with this.

If your custom field (i.e. T-shirt Size) is a selection list then you need to use issue.T-shirt Size.value to get the text value displayed in the field.

 

If the number field you are trying to set has no value in it yet, not even 0, then this doesn't work.

{{issue.T-shirt Estimation.plus(tshirtSize.get(issue.T-shirt Size.value))}}

It seems that a number field must have some numeric value in it in order for the plus function to work.

 

I used just Log actions to print values into the log rather than actually updating the issue.

For your use case substitute:

Single Select List >> T-shirt Size

SK Only Number Field >> T-shirt Estimation

Screen Shot 2023-07-03 at 1.16.40 PM.png

Like # people like this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events