Forums

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

Jira Structure Formula based on labels

Emily Urbanski October 11, 2022

I have an existing formula column to calculate a weighted score. Next, I would like to add on to those weighted scores based on label usage. My goal: if an issue has any one of the labels, it should add 10, but if it has multiple matching labels, it should add multiples of 10 (i.e. if an issue has both label1 and label2 applied, it should add 20 to the score).

IF CONTAINS(labels,"label1"): 
Weighted_Score = Weighted_Score + 10
IF CONTAINS(labels,"label2"): 
Weighted_Score = Weighted_Score + 10
IF CONTAINS(labels,"label3"): 
Weighted_Score = Weighted_Score + 10
IF CONTAINS(labels,"label4"): 
Weighted_Score = Weighted_Score + 10

The first line works, but when I add the others, I get an error. Thoughts? Ideas? Appreciate any help you can provide! 

1 answer

0 votes
David Niro
Atlassian Partner
October 11, 2022 edited

Hello @Emily Urbanski ,

I believe the reason for the error is that after the first IF function, it should be ELSE IF.  Something like

IF condition 1:
value1
ELSE IF condition 2:
value2
ELSE IF condition3...

However, based on the description of your goal, IF conditional statement probably will not return the desired results.  As soon as one of the conditions is met, it will stop.  So would not return the multiples, only ever 10.

What we will want to do here is something like this:

with value_search =
ARRAY("label 1","label 2","label 3"):
with modifier =
labels
.FILTER(value_search.CONTAINS($)).SIZE():

weightedscore + (modifier*10)

First, we will create an ARRAY of all the labels you want considered (with value_search).

Next, we FILTER the labels field, returning only labels that are found (CONTAINS) in the value_search.  Instead of returning the list of values, we will reference the SIZE, which counts the number of labels that are left.

Lastly, we can take this count, multiply it by 10 and add it to the weighted score.

Please give it a try and let me know if it helps, or if you have any additional questions!

Best,
David

Emily Urbanski October 12, 2022 edited

Thanks so much, @david! This is great!

Now to add on another layer of fun :) If I wanted to also include the search for a specific value in a custom field in addition to the 3 labels, is that possible to add that to the modifier? (i.e. if it matches the value of the custom field I'm looking for AND 1 of the labels, my modifier would be 2.)

David Niro
Atlassian Partner
October 12, 2022

Hello @Emily Urbanski ,

You are very welcome!  Yes, this is definitely possible.  We just need to add another variable for the condition and add the result to the first modifier. 

Something like this:

with value_search =
ARRAY("label 1","label 2","label 3"):
with modifier_1 =
labels
.FILTER(value_search.CONTAINS($)).SIZE():
with modifier_2 =
IF Customfield = "your_value":
1:

weightedscore + ((modifier_1+modifier_2)*10)

You will just need to map "Customfield" to the field you want to reference and change "your_value" to the one you want to include in the calculation.

Let me know if it works for you!

Best,
David

Like Kathryn Vargas _Tempo_ likes this
Emily Urbanski October 13, 2022

Thank you so very much, @David Niro ! Admittedly, never would have gotten there on my own. Really appreciate your quick responses!

Like David Niro likes this
David Niro
Atlassian Partner
October 13, 2022

You are very welcome!  happy to help!!

Like Emily Urbanski likes this

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian government cloud, fedramp, webinar, register for webinar, atlassian cloud webinar, fedramp moderate offering, work faster with cloud

Unlocking the future with Atlassian Government Cloud ☁️

Atlassian Government Cloud has achieved FedRAMP Authorization at the Moderate level! Join our webinar to learn how you can accelerate mission success and move work forward faster in cloud, all while ensuring your critical data is secure.

Register Now
AUG Leaders

Atlassian Community Events