Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
mariella2
Helper I
Helper I

Measure to calculate current closed risks

Hi, 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:

mariella2_0-1689236944002.png

 

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

mariella2_1-1689237006173.png

 


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

 

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)

 

mariella2_0-1689268947524.png

 

 

 

 

Tables:

Risk IdCreation semesterCreation DateMitigation SemesterMitigation DateMitigated
12021 H231/12/20212022 H130/06/2022Mitigated
22021 H231/12/20212021 H231/12/2021Mitigated
32022 H130/06/20222022 H130/06/2022Mitigated
42022 H130/06/20222022 H231/12/2022Mitigated
52022 H231/12/2022  Open
62022 H231/12/20222023 H130/06/2023Mitigated
1 ACCEPTED SOLUTION
mariella2
Helper I
Helper I

Solved with the following dax: 

= CALCULATE([Total Mitigated Risks], DATESBETWEEN('Calendar'[Date],BLANK(),MAX('Calendar'[Date])))
 
where Total Mitigated risks = 
CALCULATE(COUNT('Risks'[Mitigated]),'Risks'[Mitigated]="Mitigated"USERELATIONSHIP('Calendar'[Date],'Risks'[Mitigation Date]))+0

View solution in original post

5 REPLIES 5
mariella2
Helper I
Helper I

Solved with the following dax: 

= CALCULATE([Total Mitigated Risks], DATESBETWEEN('Calendar'[Date],BLANK(),MAX('Calendar'[Date])))
 
where Total Mitigated risks = 
CALCULATE(COUNT('Risks'[Mitigated]),'Risks'[Mitigated]="Mitigated"USERELATIONSHIP('Calendar'[Date],'Risks'[Mitigation Date]))+0
mariella2
Helper I
Helper I

Hi, I am bumping this post again as I still need your help.

 

I've modified a little bit the measure to this:

 

Mitigated current risks = VAR MaxDAte = MAX('Calendar'[Date]) REturn
CALCULATE(Countrows(Filter(ALL('Risks'), 'Risks'[Mitigation Date] <= MaxDate && 'Risks'[Mitigated]="Mitigated")), USERELATIONSHIP('Calendar'[Date],'Risks'[Mitigation Date]))
 
What happens is that I get the right current number of the mitigated risks for each of the semesters(meaning that the mitigated risks for the first semester are added to the mitigated risks of the next semester, and so on).
What I'd like to do with this measure is to show the current mitigated risks for each risk owner, but when I put them into table, it shows the total current mitigated risks for each risk owner. 
If I remove the 'ALL' in the measure, I get the mitigated the risks for that semester not in addition to the previous one, which is what I am looking for.
How can I solve it? Thank you in advance for your help.
mariella2_0-1690982594570.png

 




mariella2
Helper I
Helper I

any help is much appreacited.

mariella2
Helper I
Helper I

any suggestions please?

Ritaf1983
Super User
Super User

Hi @mariella2 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors