# first user assigned to issue

**URL:** <https://community.eazybi.com/t/first-user-assigned-to-issue/2181>\
**Category:** Questions & Answers\
**Tags:** mdx\
**Created:** [May 16, 2019, 12:44pm UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181 "2019-05-16T12:44:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![mc-sim](https://community.eazybi.com/user_avatar/community.eazybi.com/mc-sim/32/1637_2.png) [@mc-sim](https://community.eazybi.com/u/mc-sim)\
**Post date:** [May 16, 2019, 12:44pm UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/1 "2019-05-16T12:44:27Z")

</div>

Hi

From issue history I need to get the first user to whom the issue was assigned.

Expected result as in the screenshot

Thank you)

 ![screenshot_27](https://community.eazybi.com/uploads/default/original/2X/3/3b2631d336f15a8b8b3d3a15895101a8fd96413c.png)

---

<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:** [May 22, 2019, 1:14pm UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/2 "2019-05-22T13:14:46Z")

</div>

Hi,

There are two ways how to calculate the first assignee:

1. MDX way by creating a new calculated **measure** :

code:

```
 CASE WHEN 
[Issue].CurrentHierarchyMember.Level.Name = "Issue"
THEN
    [Assignee].[User].GetMemberbykey(
          Order(
          Filter(
          Descendants([Assignee].CurrentHierarchyMember,[Assignee].[User]),
          [Assignee].CurrentMember.Name <> "(unassigned)"
          AND
          (
          [Transition field].[Assignee],
          [Measures].[Transitions from],
          [Time].CurrentHierarchy.DefaultMember
          )>0
          ),
          ([Measures].[Transition to first timestamp],[Transition Field].[Assignee]),
          BASC
          ).item(0).key
        ).Name
END

```

This approach would calculate the first assignee for an issue.

1. use Javascript in eazyBI **[advanced settings] ([https://docs.eazybi.com/display/EAZYBIJIRA/Advanced+settings+for+custom+fields](https://docs.eazybi.com/display/EAZYBIJIRA/Advanced+settings+for+custom+fields))** when defining a new calculated custom field to calculate the first assignee from the changelog and then import results as new property for Issue dimension members

code:

```
[jira.customfield_firstassignee]
name = "First assignee"
data_type = "string"
javascript_code = '''
var assignee_dname;
if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
var histories = issue.changelog.histories;
for (var i = 0; i < histories.length; i++) {
var history = histories[i];
if (history.items && history.items.length > 0) {
for (var n = 0; n < history.items.length; n++) {
var item = history.items[n];
if (item.field == 'assignee' && item.toString) {
assignee_dname = item.toString;
}
}
}
if(assignee_dname){
break;
}
}
}
issue.fields.customfield_firstassignee = assignee_dname;
'''

```

In some specific scenarios (assignee is set during creation) both approaches may return different results for an issue.

Martins / eazyBI support

---

<div class="post-metadata">

**Author:** ![gsunil.kumar](https://community.eazybi.com/letter_avatar_proxy/v4/letter/g/2bfe46/32.png) [@gsunil.kumar](https://community.eazybi.com/u/gsunil.kumar)\
**Post date:** [June 8, 2022, 7:51am UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/3 "2022-06-08T07:51:37Z")

</div>

> [@martins.vanags](#):
>
> ```auto
> javascript_code = '''
> var assignee_dname;
> if (issue.changelog && issue.changelog.histories && issue.changelog.histories.length > 0) {
> var histories = issue.changelog.histories;
> for (var i = 0; i < histories.length; i++) {
> var history = histories[i];
> if (history.items && history.items.length > 0) {
> for (var n = 0; n < history.items.length; n++) {
> var item = history.items[n];
> if (item.field == 'assignee' && item.toString) {
> assignee_dname = item.toString;
> }
> }
> }
> if(assignee_dname){
> break;
> }
> }
> }
> issue.fields.customfield_firstassignee = assignee_dname;
> '''
> 
> ```

Hi Martins,

I tried to use the same but can this be used to get the first Date set for the Due Date field rather than the current date

---

<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:** [June 9, 2022, 8:27am UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/4 "2022-06-09T08:27:17Z")

</div>

@gsunil.kumar  
when using eazyBI for Jira Server or Datecanter, eazyBI won’t import the history for Due date field.  
You can try a similar script (as above) for some of your own custom fields.  
I believe this community post could be useful to find the initial date value:

> [@Initial "Target End" date](https://community.eazybi.com/t/initial-target-end-date/8670):
>
> Hi all, Is it possible to show the first “Target End” date that was set in a JIRA ticket? I would like to see what the initial planned date was, and what it was when the feature was completed, sort of a planned vs. actual date. Thank you!

Martins / eazyBI

---

<div class="post-metadata">

**Author:** ![gsunil.kumar](https://community.eazybi.com/letter_avatar_proxy/v4/letter/g/2bfe46/32.png) [@gsunil.kumar](https://community.eazybi.com/u/gsunil.kumar)\
**Post date:** [June 28, 2022, 11:07am UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/5 "2022-06-28T11:07:56Z")

</div>

Thanks Martins.

It helped.

Regards,  
Sunil

---

<div class="post-metadata">

**Author:** ![Taylor\_Quinn](https://community.eazybi.com/user_avatar/community.eazybi.com/taylor_quinn/32/9415_2.png) [@Taylor\_Quinn](https://community.eazybi.com/u/Taylor_Quinn)\
**Post date:** [July 13, 2023, 5:40pm UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/6 "2023-07-13T17:40:05Z")

</div>

Is there a way to create a calculated measure that shows the second assignee of a ticket?

---

<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:** [July 17, 2023, 6:05am UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/7 "2023-07-17T06:05:54Z")

</div>

@Taylor_Quinn

Try creating new calculated measure using this formula:

```auto
CASE 
  WHEN
    [Issue].CurrentHierarchyMember.level.name = "Issue"
    AND
    [Measures].[Transitions to assignee]>0
  THEN
    Generate(
      Head(
        Order(
          Filter(
            DescendantsSet([Assignee].CurrentMember,[Assignee].[User]),
            [Assignee].CurrentMember.name <> "(Unassigned)"
            AND
            (
              [Measures].[Transitions to assignee],
              [Time].CurrentHierarchy.DefaultMember
            )>0
          ),
          (
            [Measures].[Transition to first timestamp],
            [Transition Field].[Assignee],
            [Time].CurrentHierarchy.DefaultMember
          ),
          BASC
        ),
        2
      ).item(1),
      [Assignee].CurrentMember.name,
      Chr(10)
    )
END

```

Martins / eazyBI

---

<div class="post-metadata">

**Author:** ![Taylor\_Quinn](https://community.eazybi.com/user_avatar/community.eazybi.com/taylor_quinn/32/9415_2.png) [@Taylor\_Quinn](https://community.eazybi.com/u/Taylor_Quinn)\
**Post date:** [July 17, 2023, 3:56pm UTC](https://community.eazybi.com/t/first-user-assigned-to-issue/2181/8 "2023-07-17T15:56:41Z")

</div>

Thank you @martins.vanags! This is exactly what I needed
