# Issues created out of office hours

**URL:** <https://community.eazybi.com/t/issues-created-out-of-office-hours/180>\
**Category:** Tips & Tricks\
**Tags:** calculatedmembers\
**Created:** [October 12, 2017, 12:13pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180 "2017-10-12T12:13:02Z")\
**Posts on this page:** 20\
**Page:** 1

<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:** [October 12, 2017, 12:13pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/1 "2017-10-12T12:13:02Z")

</div>

There are a couple of ways how to calculate the number of issues created outside office hours.

First, let us look at an example to **find issues created before 9 am or after 6 pm** in eazyBI.  
To do this, you can define a **created hour** breakdown dimension with [advanced settings](https://docs.eazybi.com/eazybijira/data-import/custom-fields/advanced-settings-for-custom-fields):

```auto
[jira.customfield_hodc]
name = "Hour of Day Created"
data_type = "integer"
dimension = true
javascript_code = '''
issue.fields.customfield_hodc = parseInt(issue.fields.created.match(/T(\d\d):/)[1]);
'''

```

Further, select the new dimension for import from the data import screen as a new dimension. You will be able to create the following report and even highlight the most active and passive times of the day:

 ![Created_1](https://community.eazybi.com/uploads/default/original/2X/d/df791cbffc1f6bbab49e58578577a173da86035a.png)

Further, you can create a calculated member in Measure that sums the total issues created outside working hours (before 9 am and after 6 pm):

```
Sum(
  Filter(
    Except([Hour of Day Created].[Hour of Day Created].Members,
    [Hour of Day Created].[(none)]), 
  Val([Hour of Day Created].CurrentHierarchyMember.Name) < 9 OR 
  Val([Hour of Day Created].CurrentHierarchyMember.Name) >= 18
), [Measures].[Issues created])

```

 ![Created_2](https://community.eazybi.com/uploads/default/original/2X/4/41f927efc9e6cd2c222032056e42ee55cc4e6983.png)

Secondly, there is **another option** without importing the additional **Created hour** dimension. While this would also work for hours only, this approach can be slower and is suggested only if the working hours are not full, e.g., **9 AM to 5:30 PM**.

In such a case, please create a new calculated member in the **Measures** dimension using the following code:

```
NonZero([Measures].[Issues created] - -- total created issues minus created during working h
Count(Filter(
  Descendants([Issue].CurrentMember, [Issue].[Issue]),
  DateInPeriod(
    [Issue].CurrentMember.get('Created at'),
    [Time].CurrentHierarchyMember) AND -- created date in the period
  [Measures].[Issues created] > 0 AND -- issue is created in selected report context
  ((Hour(DateParse([Issue].CurrentMember.get('Created at'))) >= 9 AND -- created hour is after 9
    Hour(DateParse([Issue].CurrentMember.get('Created at'))) < 17 -- created before 17
  ) OR (
    Hour(DateParse([Issue].CurrentMember.get('Created at'))) = 17 AND -- if the hour is 17
    Minute(DateParse([Issue].CurrentMember.get('Created at'))) < 30 -- then created is before 17:30
  ))
)))

```

Cheers!

---

<div class="post-metadata">

**Author:** ![HelenG](https://community.eazybi.com/letter_avatar_proxy/v4/letter/h/3d9bf3/32.png) [@HelenG](https://community.eazybi.com/u/HelenG)\
**Post date:** [May 3, 2019, 3:08pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/2 "2019-05-03T15:08:05Z")

</div>

This would be really useful, however I can’t get it to work without timing out. Any suggestions?

---

<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 8, 2019, 4:28am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/3 "2019-05-08T04:28:25Z")

</div>

Hi,

You could try **enabling** the “Nonempty” cross-join for rows dimensions

 ![Nonempty](https://community.eazybi.com/uploads/default/original/2X/3/3440db7f816ba094c5b920fb8e3159baa625c9b3.jpeg)

Martins / eazyBI support

---

<div class="post-metadata">

**Author:** ![Izabella\_Cikalova](https://community.eazybi.com/letter_avatar_proxy/v4/letter/i/a8b319/32.png) [@Izabella\_Cikalova](https://community.eazybi.com/u/Izabella_Cikalova)\
**Post date:** [July 2, 2021, 8:09pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/4 "2021-07-02T20:09:53Z")

</div>

> [@martins.vanags](#):
>
> ```auto
> [jira.customfield_hour_of_day_created]
> name = "Created hour"
> data_type = "integer"
> dimension = true
> javascript_code = '''
> var createDate = new Date(Date.parse(issue.fields.created));
> var hours = createDate.getHours() - (createDate.getTimezoneOffset() / 60) ;
> issue.fields.customfield_hour_of_day_created = hours;
> '''
> 
> ```

Hi, I would like to create the same report with issues closed in office hours and out of office hours. Please, could you advise how to achieve this

---

<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 5, 2021, 7:27am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/5 "2021-07-05T07:27:07Z")

</div>

@Izabella_Cikalova

Try importing from issue.fields. **resolutiondate** to get the hours from resolution date timestamp.

Martins / eazyBI support

---

<div class="post-metadata">

**Author:** ![Fra](https://community.eazybi.com/user_avatar/community.eazybi.com/fra/32/2695_2.png) [@Fra](https://community.eazybi.com/u/Fra)\
**Post date:** [June 14, 2022, 2:57pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/6 "2022-06-14T14:57:43Z")

</div>

Hi Martins  
how can i find out about the tickets created only during the weekend?

---

<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 15, 2022, 6:03am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/7 "2022-06-15T06:03:39Z")

</div>

@Fra

Try creating new calculated measure using this formula:

```auto
Aggregate({
[Week Day].[Saturday],
[Week Day].[Sunday]}
,
[Measures].[Issues created]
)

```

That would calculate the issues created on Sundays and Saturdays.

Martins / eazyBI

---

<div class="post-metadata">

**Author:** ![Fra](https://community.eazybi.com/user_avatar/community.eazybi.com/fra/32/2695_2.png) [@Fra](https://community.eazybi.com/u/Fra)\
**Post date:** [June 15, 2022, 9:06am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/8 "2022-06-15T09:06:59Z")

</div>

Thank you @martins.vanags for you help.

---

<div class="post-metadata">

**Author:** ![jayplayd](https://community.eazybi.com/letter_avatar_proxy/v4/letter/j/c5a1d2/32.png) [@jayplayd](https://community.eazybi.com/u/jayplayd)\
**Post date:** [May 9, 2023, 5:37am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/9 "2023-05-09T05:37:54Z")

</div>

Hi @martins.vanags,  
I am trying to get this solution to work based on the start date but so far I am not successful.  
What would be the correct syntax for the required start date hour dimension?

Thank you very much!

```auto
[jira.customfield_hodc]
name = "Hour of Day Created"
data_type = "integer"
dimension = true
javascript_code = '''
issue.fields.customfield_hodc = parseInt(issue.fields.created.match(/T(\d\d):/)[1]);
'''

```

---

<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 9, 2023, 5:49am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/10 "2023-05-09T05:49:51Z")

</div>

@jayplayd

Most likely the start date is stored as **customfield\_NNNNN** in jira (replace NNNNN with custom field ID).  
Locate the custom field ID in Jira for “start date” and then use it in the Javascript.

```auto
[jira.customfield_hodsd]
name = "Hour of Day Start date"
data_type = "integer"
dimension = true
javascript_code = '''
issue.fields.customfield_hodsd = parseInt(issue.fields.customfield_NNNNN.match(/T(\d\d):/)[1]);
'''

```

Martins / eazyBI

---

<div class="post-metadata">

**Author:** ![jayplayd](https://community.eazybi.com/letter_avatar_proxy/v4/letter/j/c5a1d2/32.png) [@jayplayd](https://community.eazybi.com/u/jayplayd)\
**Post date:** [May 9, 2023, 6:33am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/11 "2023-05-09T06:33:11Z")

</div>

Thanks for the quick reply. I changed the customfield definition accordingly but now I get an error when importing:

 ![grafik](https://community.eazybi.com/uploads/default/original/2X/d/dd357a358dd88eb6dc21131799623db418ff4ffd.png)

# Hour of Day Start Date

[jira.customfield\_hods]  
name = “Hour of Day Start Time”  
data\_type = “integer”  
dimension = true  
javascript\_code = ‘’’  
issue.fields.customfield\_hods = parseInt(issue.fields.customfield\_10944.match(/T(\d\d):/)[1]);  
‘’’

The field configuration looks the same as the created date field though:

 ![grafik](https://community.eazybi.com/uploads/default/original/2X/7/70e1381e761e8aef8faedabdd8cf27bc9df13b0a.png)

Do you have an idea where the error comes from?

Thank you so much!

---

<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 9, 2023, 6:45am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/12 "2023-05-09T06:45:02Z")

</div>

@jayplayd

The error is because of issues where the start date is not entered.

Try additional validation to the script.

```auto
[jira.customfield_hodsd]
name = "Hour of Day Start date"
data_type = "integer"
dimension = true
javascript_code = '''
if(issue.fields.customfield_10944){
issue.fields.customfield_hodsd = parseInt(issue.fields.customfield_10944.match(/T(\d\d):/)[1]);
}
'''

```

Martins / eazyBI

---

<div class="post-metadata">

**Author:** ![jayplayd](https://community.eazybi.com/letter_avatar_proxy/v4/letter/j/c5a1d2/32.png) [@jayplayd](https://community.eazybi.com/u/jayplayd)\
**Post date:** [May 9, 2023, 12:46pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/13 "2023-05-09T12:46:23Z")

</div>

Hi @martins.vanags,  
this works like a charm.  
Thank you again - you made someones day today!  
Best regards  
Jay

---

<div class="post-metadata">

**Author:** ![Leandimoll90](https://community.eazybi.com/letter_avatar_proxy/v4/letter/l/b5ac83/32.png) [@Leandimoll90](https://community.eazybi.com/u/Leandimoll90)\
**Post date:** [March 8, 2024, 2:27pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/14 "2024-03-08T14:27:08Z")

</div>

Hi @martins.vanags ,

If I want to try the same report but for issues resolved outside business hours then I get an error when using issue.fields. **resolutiondate**

It states:  
Cannot call method “match” of null

Could you assist please?

---

<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:** [March 11, 2024, 6:00am UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/15 "2024-03-11T06:00:16Z")

</div>

Hi,  
See a similar use-case here:

> [@Issues created out of office hours](https://community.eazybi.com/t/issues-created-out-of-office-hours/180):
>
> There are a couple of ways how to calculate the number of issues created outside office hours. First, let us look at an example to find issues created before 9 am or after 6 pm in eazyBI. To do this, you can define a created hour breakdown dimension with [advanced settings](https://docs.eazybi.com/eazybijira/data-import/custom-fields/advanced-settings-for-custom-fields): [jira.customfield\_hodc] name = "Hour of Day Created" data\_type = "integer" dimension = true javascript\_code = ''' issue.fields.customfield\_hodc = parseInt(issue.fields.created.match(/T(\d\d):/)[1]); ''' Further, select the…

In your case, **issue.fields.resolutiondate** must be used.

Martins / eazyBI

---

<div class="post-metadata">

**Author:** ![Leandimoll90](https://community.eazybi.com/letter_avatar_proxy/v4/letter/l/b5ac83/32.png) [@Leandimoll90](https://community.eazybi.com/u/Leandimoll90)\
**Post date:** [March 13, 2024, 12:41pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/16 "2024-03-13T12:41:26Z")

</div>

> [@Issues created out of office hours](#):
>
> match

Hi Martins, I have updated the field as below but receive an error:  
[jira.customfield\_hodc]  
name = “Hour of Day Created”  
data\_type = “integer”  
dimension = true  
javascript\_code = ‘’’  
issue.fields.customfield\_hodc = parseInt(issue.fields.resolutiondate.match(/T(\d\d):/)[1]);  
‘’’  
 ![image](https://community.eazybi.com/uploads/default/original/2X/4/4ad89e7760e4387833d2dbd812b631ff128db6bc.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:** [March 13, 2024, 1:04pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/17 "2024-03-13T13:04:09Z")

</div>

Try this definition instead:

```auto
[jira.customfield_horesd]
name = "Hour of Resolution"
data_type = "integer"
dimension = true
javascript_code = '''
if(issue.fields.resolutiondate){
issue.fields.customfield_horesd = parseInt(issue.fields.resolutiondate.match(/T(\d\d):/)[1]);
}
'''

```

Martins / eazyBI

---

<div class="post-metadata">

**Author:** ![Leandimoll90](https://community.eazybi.com/letter_avatar_proxy/v4/letter/l/b5ac83/32.png) [@Leandimoll90](https://community.eazybi.com/u/Leandimoll90)\
**Post date:** [March 13, 2024, 2:27pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/18 "2024-03-13T14:27:56Z")

</div>

> [@martins.vanags](#):
>
> ```auto
> Sum(
> Filter(
> Except([Created hour].[Created hour].Members,
> [Created hour].[(none)]), 
> Val([Created hour].CurrentHierarchyMember.Name) < 9 OR 
> Val([Created hour].CurrentHierarchyMember.Name) >= 18
> ), [Measures].[Issues created])
> 
> ```

This is working now! Thank you so much!!

---

<div class="post-metadata">

**Author:** ![pbenati](https://community.eazybi.com/letter_avatar_proxy/v4/letter/p/c67d28/32.png) [@pbenati](https://community.eazybi.com/u/pbenati)\
**Post date:** [August 28, 2024, 1:11pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/19 "2024-08-28T13:11:03Z")

</div>

Martins – What time zone is this report referring to? Thanks.

---

<div class="post-metadata">

**Author:** ![pbenati](https://community.eazybi.com/letter_avatar_proxy/v4/letter/p/c67d28/32.png) [@pbenati](https://community.eazybi.com/u/pbenati)\
**Post date:** [August 28, 2024, 1:39pm UTC](https://community.eazybi.com/t/issues-created-out-of-office-hours/180/20 "2024-08-28T13:39:53Z")

</div>

Martins – How are you color-coding the cells of the report? Thanks.

[Next page](https://community.eazybi.com/t/issues-created-out-of-office-hours/180.md?page=2)
