# Count occurences of same option on several select list custom fields

**URL:** <https://community.eazybi.com/t/count-occurences-of-same-option-on-several-select-list-custom-fields/3182>\
**Category:** Questions & Answers\
**Created:** [November 13, 2019, 7:50pm UTC](https://community.eazybi.com/t/count-occurences-of-same-option-on-several-select-list-custom-fields/3182 "2019-11-13T19:50:11Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![acelsodd](https://community.eazybi.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@acelsodd](https://community.eazybi.com/u/acelsodd)\
**Post date:** [November 13, 2019, 7:50pm UTC](https://community.eazybi.com/t/count-occurences-of-same-option-on-several-select-list-custom-fields/3182/1 "2019-11-13T19:50:12Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![martins.vanags](https://community.eazybi.com/user_avatar/community.eazybi.com/martins.vanags/32/8905_2.png) [@martins.vanags](https://community.eazybi.com/u/martins.vanags)\
**Post date:** [November 21, 2019, 1:09pm UTC](https://community.eazybi.com/t/count-occurences-of-same-option-on-several-select-list-custom-fields/3182/2 "2019-11-21T13:09:51Z")

</div>

Hi Antonio,

In this case, you could create a new calculated custom field with [**Javascript**](https://docs.eazybi.com/eazybijira/data-import/custom-fields/javascript-calculated-custom-fields) 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

 ![Combined%20origin](https://community.eazybi.com/uploads/default/original/2X/1/1ac737873af34cfbdc35628a7dfb8d6141c08d2d.png)

---

<div class="post-metadata">

**Author:** ![acelsodd](https://community.eazybi.com/letter_avatar_proxy/v4/letter/a/edb3f5/32.png) [@acelsodd](https://community.eazybi.com/u/acelsodd)\
**Post date:** [November 21, 2019, 3:54pm UTC](https://community.eazybi.com/t/count-occurences-of-same-option-on-several-select-list-custom-fields/3182/3 "2019-11-21T15:54:29Z")

</div>

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.
