Measure to calculate current closed risks

32 views Asked by At

I need help with a measure to calculate current closed risks. I have the risk table linked to the calendar[Date] table with an active relationship in Creation Date and one inactive for Mitigation Date (Closing risk date). The measure I use is the following:

Mitigated risks = var selectedDate = Max('Calendar[Date]) VAr FilteredTable = Filter('Risk', 'Risk'[Mitigation Date] <= selectedDate && 'Risk'[Mitigated]="Mitigated") RETURN Countrows(FilteredTable)

This measure works ok, but when I use it in a visual and filter by a slicer with Calendar[Date] as the field, it behaves strangely. If I select the first semester (H2 2021), it displays the correct count of closed risks,

if I select the next semester (H1 2022), it goes blank and it is blank for all subsequent semesters.

This shows that the measure works with the first date in the slicer:

enter image description here

This is to show that starting from the next semester in the slicer, the measure goes blank.

enter image description here

What is missing in the measure so that it displays the correct count for each semester? Any help is appreciated.

Tables:

Risk Id Creation Semester
1 2021 H2
2 2021 H2
3 2022 H1
4 2022 H1
5 2022 H2
6 2022 H2
Creation Date Mitigation Semester
31/12/2021 2022 H1
31/12/2021 2021 H2
30/06/2022 2022 H1
30/06/2022 2022 H2
31/12/2022
31/12/2022 2023 H1
Mitigation Date Mitigated
30/06/2022 Mitigated
31/12/2021 Mitigated
30/06/2022 Mitigated
31/12/2022 Mitigated
Open
30/06/2023 Mitigated

Edit: if I add 'ALL' to the measure, it works ok for the semester. But if I add it to bar chart with risk owner on the other axis, I get the same total per each user.

Mitigated risks = var selectedDate = Max('Calendar[Date]) VAr FilteredTable = Filter(ALL('Risk'), 'Risk'[Mitigation Date] <= selectedDate && 'Risk'[Mitigated]="Mitigated") RETURN Countrows(FilteredTable)

enter image description here

0

There are 0 answers