# AVG Calculation

**URL:** <https://community.eazybi.com/t/avg-calculation/13570>\
**Category:** Questions & Answers\
**Tags:** jira\
**Created:** [August 24, 2023, 10:31pm UTC](https://community.eazybi.com/t/avg-calculation/13570 "2023-08-24T22:31:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![agudipelli](https://community.eazybi.com/letter_avatar_proxy/v4/letter/a/b77776/32.png) [@agudipelli](https://community.eazybi.com/u/agudipelli)\
**Post date:** [August 24, 2023, 10:31pm UTC](https://community.eazybi.com/t/avg-calculation/13570/1 "2023-08-24T22:31:23Z")

</div>

Hi All,

Here is the definition I have

Avg(  
Filter(Descendants([Issue].CurrentMember,[Issue].[Issue]),  
([Measures].[Customfield\_One])\>0),  
CASE WHEN  
DateCompare([Measures].[Date\_One],DateParse(‘Apr 30, 2021’))\>0  
AND  
DateInPeriod([Measures].[Date\_Two],[Time])  
AND  
IsEmpty([Measures].[Date\_Three])  
THEN  
DateDiffWorkdays([Measures].[Date\_Two],DateParse(‘today’))

WHEN  
DateCompare([Measures].[Date\_One],DateParse(‘Apr 30, 2021’))\>0  
AND  
DateInPeriod([Measures].[Date\_Two],[Time])  
AND  
NOT IsEmpty([Measures].[Date\_Three])  
THEN  
DateDiffWorkdays([Measures].[Date\_Two],[Measures].[Date\_Three])

End)

I am able to get the avgs, but there are issues that are closed/completed and the avg is still counting.  
I am thinking of adding another date field called “Date\_Four” and automatically updating the date when the issues closed/completed, so the avg can be calculated accordingly.  
Now, how can I include the “Date\_Four” in my calculation/definition?

Please Help.

---

<div class="post-metadata">

**Author:** ![janis.plume](https://community.eazybi.com/user_avatar/community.eazybi.com/janis.plume/32/8826_2.png) [@janis.plume](https://community.eazybi.com/u/janis.plume)\
**Post date:** [August 31, 2023, 10:48am UTC](https://community.eazybi.com/t/avg-calculation/13570/2 "2023-08-31T10:48:21Z")

</div>

Hi,

The most straightforward solution for filtering unresolved issues is to check the resolution in the filter condition:

```auto
Avg(
Filter(Descendants([Issue].CurrentMember,[Issue].[Issue]),
([Measrures].[Issue resolution]="(unresolved)" AND [Measures].[Customfield_One])>0),
CASE WHEN
DateCompare([Measures].[Date_One],DateParse(‘Apr 30, 2021’))>0
AND
DateInPeriod([Measures].[Date_Two],[Time])
AND
IsEmpty([Measures].[Date_Three])
THEN
DateDiffWorkdays([Measures].[Date_Two],DateParse(‘today’))

WHEN
DateCompare([Measures].[Date_One],DateParse(‘Apr 30, 2021’))>0
AND
DateInPeriod([Measures].[Date_Two],[Time])
AND
NOT IsEmpty([Measures].[Date_Three])
THEN
DateDiffWorkdays([Measures].[Date_Two],[Measures].[Date_Three])

End)

```

Kindly,  
Janis, eazyBI support
