Extract department name from the Reporter dimension

Greetings everyone,

I am having trouble to extract the department name from the Reporter user field when set as a dimension.
When I pull the reporter field dimension into rows, I want to be able to extract the department name from Reporters (username) and group values by departments.
i.e. first_name last_name (Department A) → I want to be able to only extract the “Department A” value and group the number of issues created by that department.

1 Like

Hi @Marko_Slijepcevic1

One idea is to define a new calculated field from the import options page that imports Department from reporter’s name during data imports and create a new dimension from these substrings.

Try this Javascript for new calculated field:

var rep = issue.fields.reporter;
var rep_dpmnt = "";
const regex = /\((.*?)\)/; // This regex captures anything inside parentheses

if(rep)
  var matches = rep.displayName.match(regex);
    if (matches) {
      rep_dpmnt = matches[1];
    }
return rep_dpmnt;

Martins / eazyBI



hey @martins.vanags thanks a lot! Works as a charm :slight_smile: