# Calculate remaining time

**URL:** <https://community.eazybi.com/t/calculate-remaining-time/14482>\
**Category:** Questions & Answers\
**Created:** [December 8, 2023, 9:50pm UTC](https://community.eazybi.com/t/calculate-remaining-time/14482 "2023-12-08T21:50:26Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oksana\_Dovha](https://community.eazybi.com/user_avatar/community.eazybi.com/oksana_dovha/32/11220_2.png) [@Oksana\_Dovha](https://community.eazybi.com/u/Oksana_Dovha)\
**Post date:** [December 8, 2023, 9:50pm UTC](https://community.eazybi.com/t/calculate-remaining-time/14482/1 "2023-12-08T21:50:26Z")

</div>

Hello,

I have a simple formula for calculating “Remaining time”, but it does not work correctly.

```auto
(
([Measures].[Original estimated hours] +
[Measures].[Sub-tasks original estimated hours]
-
([Measures].[Hours spent] +
[Measures].[Sub-tasks hours spent]))
)

```

If I have the next tasks:  
Task\_1:  
estimate=10 hours  
spent\_time=6 hours

Task\_2:  
estimate=12 hours  
spent\_time=14 hours

my formula will calculate the sum of the remaining time as  
(10+12)-(6+14)=22-20=2 hours  
but it is incorrect.  
for Task\_1 remaining\_time is 10-6=4 hours  
for Task\_2 remaining\_time is 0 (because we have already spent more time than estimated)  
The total sum of remaining time should be 4 hours, not 2 hours as the formula calculated.

As I understand there should be something like cycle “for (…)”, but I can’t find a solution how to write in eazyBI.  
I would appreciate your help.

---

<div class="post-metadata">

**Author:** ![Elita.Kalane](https://community.eazybi.com/user_avatar/community.eazybi.com/elita.kalane/32/14957_2.png) [@Elita.Kalane](https://community.eazybi.com/u/Elita.Kalane)\
**Post date:** [January 23, 2024, 12:51pm UTC](https://community.eazybi.com/t/calculate-remaining-time/14482/2 "2024-01-23T12:51:17Z")

</div>

Hello @Oksana_Dovha

It seems that you reached out to us directly.  
I’m posting a possible solution here in case other eazyBI users face a similar problem.

For this use case, the import of the inherited field dimension might be useful.  
Here is a documentation that explains how to Import the inherited field dimension: [JavaScript calculated custom fields](https://docs.eazybi.com/eazybi/data-import/data-from-jira/jira-custom-fields/javascript-calculated-custom-fields#JavaScriptcalculatedcustomfields-Inheritedfielddimension)

And here is a community post about a similar use-case - [Calculating Total user stories based on epics fields - #2 by janis.plume](https://community.eazybi.com/t/calculating-total-user-stories-based-on-epics-fields/4735/2)

Best wishes,  
Elita from [support@eazybi.com](mailto:support@eazybi.com)
