Count occurences of same option on several select list custom fields

I have a JIRA issue that classifies up to 5 items according to their origin type. (And we have 40 different origin types possible!)
As we do not have arrays as JIRA custom fields, I created 5 custom fields of type Select List (Single) each of these custom fields with all the 40 selectable origins.
Let’s name them Origin1, Origin2, Origin3, Origin4, and Origin5.

The very first option of the Select List is “Make a choice” and starting on the second option, I have the names of all the 40 possible origins.
So, If some of these custom fields just has the option “Make a choice”, I know that it is NOT used. Easy like that.
Well, considering all the JIRA issues that use such fields, I need to count for each origin type (it doesn’t matter if the origin type was selected on Origin1, Origin2, Origin3, Origin4 or Origin5 custom field) how many they are. See this example (very simplified):

Issue--------- Field ‘Origin 1’--------- Field ‘Origin 2’---------------Field ‘Origin 3’
JIR-1----------ESP--------------------------MAC-----------------------------Make a choice
JIR-5----------DIF---------------------------MAC-----------------------------ESP
JIR-8----------MAC------------------------GRD-------------------------------Make a choice
JIR-12--------ESP-------------------------GRD-------------------------------DIF

I need tho show a graphic with such totals:

Origin ESP ------------------------------ 3 occurences
Origin MAC ----------------------------- 3 occurences
Origin DIF -------------------------------- 2 occurences
Origin GRD ------------------------------ 2 occurences
‘Make a choice’ ----------------------- Must not be counted

I really appreciate your help.
Thanks a lot.
Antonio Duarte.

Hi Antonio,

In this case, you could create a new calculated custom field with Javascript in eazyBI advanced settings.

[jira.customfield_neworigin]
name = "Combined origin"
data_type = "string"
dimension = true
multiple_values = true
split_by = ","
javascript_code = '''
var or1 = issue.fields.customfield_xxxx1;
var or2 = issue.fields.customfield_xxxx2;
var or3 = issue.fields.customfield_xxxx3;

if(or1 && or2 && or3){
  issue.fields.customfield_neworigin = 
  or1.value+","+or2.value+","+or3.value 
}
'''

Here I assume that all 3 custom fields are mandatory and can’t be empty.
And you must replace xxxx1, xxxx2, and xxxx3 with actual custom field ID’s in this code
Note that all 3 original customfields also should be selected and imported in eazyBI (as properties)

Then you can import this new field as a separate dimension and use in a report with a measure “issues created count”
Finally, you could remove the member “Make a choice” from the report by clicking on it from the table and chosing the “remove” option.

Martins / eazyBI team

Hi, @martins.vanags,

That was exactly the kind of totals I was looking for.
Thank you very much for your awesome help!

Best regards.
Antonio.