Hi @tulliodisimone,
Welcome to the eazyBI community. Your question and the provided details are spot on! Sorry, it took a while to give you an answer.
In the detailed “Issue” level, eazyBI can retrieve both dates. Thus it can return the result you require. However, in the “Project”, “All” levels, and the total, the dates are empty, and eazyBI can’t determine a result.
To overcome that, I recommend splitting the calculation into two parts. The first part determines the result in the “Issue” level. The second part will take care of the upper levels. You can do that with the CASE
statement. See the first attempt at the calculation below:
CASE WHEN
-- determine Issue dimension level
[Issue].CurrentHierarchyMember.Level.Name = 'Issue'
THEN
DateDiffDays(
[Measures].[End Date],
[Measures].[Issue Target end]
)
END
Now, to get the results in levels other than “Issue”, the calculation must iterate through these issues, calculate the values, and sum them in the ELSE branch. eazyBI can do that with the help of the Descendants() function. To improve its performance, I recommend using the Filter() function to reduce the number of considered issues. See the whole calculation below with comments:
CASE WHEN
-- determine Issue dimension level
[Issue].CurrentHierarchyMember.Level.Name = 'Issue'
THEN
DateDiffDays(
[Measures].[End Date],
[Measures].[Issue Target end]
)
ELSE
Sum( -- sum the total. Use Avg() to calculate the average
Filter(
-- iterate through issues and filter to retrieve relevant issues
Descendants([Issue].CurrentMember,[Issue].[Issue]),
-- filter conditions
Not IsEmpty([Measures].[End Date])
AND
Not IsEmpty([Measures].[Issue Target end])
),
-- numeric expression to evaluate the issues
CASE WHEN [Measures].[Issues created] > 0
THEN
DateDiffDays(
[Measures].[End Date],
[Measures].[Issue Target end]
)
END
)
END
See an example with different dates below:
Suppose you add the Time dimension to the report, for example, the pages, and select a specific period. In that case, the report will retrieve the issues created in the selected period. Let me know if that is a viable scenario and if you would want to change that.
Please look at the eazyBI documentation page for more information on defining calculated measures -Calculated measures and members.
Best,
Roberts // support@eazybi.com