I want to enable import as measure for a custom filed in eazyBI

How to enable import as measure for a custom filed of type Single Select List having numerical values in eazyBI.

For that custom field already there is code written as below

[jira.customfield_xxxxx]
data_type=“string”
dimension=true
separate_table = true
changes = true

What additional lines I need to add to enable import as measure.

Hi @Rajesh,
Welcome to the eazyBI community! :wave:

In this case, when your field is Single Select List you need to use the JavaScript custom field to import it as a measure. It is because of the way how the field contains its values and it needs the additional calculation to retrieve this data.

Here is a code for it (replace NNNNN with your customfield ID):

# Select List as measure
[jira.customfield_NNNNN]
data_type = "integer"
measure = true
javascript_code = '''
// create new function which can convert string to number
function setNumber(str)
{
  num = Number(str);
  if ( Object.prototype.toString.call(num) === "[object Number]" && !isNaN( num )) {
    return num;
  }
  else {
    return null;
  }
};
// transforms custom field value to string using new function
if(issue.fields.customfield_NNNNN && issue.fields.customfield_NNNNN.value) {
  str = issue.fields.customfield_NNNNN.value;
  issue.fields.customfield_NNNNN = setNumber(str);
}
'''  

Here you will find more information on how to add the customfield to your eazyBI - https://docs.eazybi.com/eazybijira/data-import/custom-fields/javascript-calculated-custom-fields

best,
Gerda // support@eazyBI.com