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!
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
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.)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thank you so very much, @David Niro ! Admittedly, never would have gotten there on my own. Really appreciate your quick responses!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 NowOnline forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.