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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
PhillipC1
Helper I
Helper I

Dax Formula to get clean stop rate

Hello,

 

I am trying to figure out the dax formula to utilize to obtain a clean stop rate which is number of violations divided by number of inspections. The kicker is that one inspection could have more than one violation which is where I am running into my problem. In the table below, I show some sample data where there are a total of three inspections (Distinct Report Numbers) and two violations (Violation_Count) belonging to the same inspection. In the formula I only want one violation per inspection to be counted if applicable. 

 

This is my current dax formula:

 

Clean Stop Rate = 1-CALCULATE(DIVIDE(SUM('CSA Extract'[VIOLATION_COUNT]),DISTINCTCOUNT('CSA Extract'[REPORT_NUMBER])))

 

 

This is the table for the data:

IDREPORT_NUMBERINSPECTION_RESULTBASICCATEGORYINSPECTION_DATEPOST_DATEVIOLATION_COUNT
729896FYD0XBXFYViolationVehicle MaintenanceTires11/11/202211/22/20221
729896FYD0XBXFYViolationVehicle MaintenanceGeneral Securement11/11/202211/22/20221
729896C2B0XCHLGClean  6/24/20226/28/20220
729896DWE0XJSUEClean  8/29/20229/1/20220

 

My problem is that with that DAX formula, I am returning a result of 33% when I actually need to return 66% as the formula should be more along the lines of below:

 

3 Inspections Total

2 Inspections = Clean

1 Insepction = Violation

 

Meaning that 2 clean inspections divded by 3 total inspections would equal 66.66%

 

I feel like I am just missing something and maybe my brain is fried from the development on this dashboard, but figured I would reach out to see if anyone has a solution. 

1 ACCEPTED SOLUTION
JamesFR06
Resolver IV
Resolver IV

HI

 

var Clean=calculate(DISTINCTCOUNT('CSA Extract'[REPORT_NUMBER]),'CSA Extract'[INSPECTION_RESULT]="Clean")

var _Ttlinspections = calculate(DISTINCTCOUNT('CSA Extract'[REPORT_NUMBER]),all(CSA Extract))

return

divide(Clean,_Ttlinspections)

View solution in original post

2 REPLIES 2
JamesFR06
Resolver IV
Resolver IV

HI

 

var Clean=calculate(DISTINCTCOUNT('CSA Extract'[REPORT_NUMBER]),'CSA Extract'[INSPECTION_RESULT]="Clean")

var _Ttlinspections = calculate(DISTINCTCOUNT('CSA Extract'[REPORT_NUMBER]),all(CSA Extract))

return

divide(Clean,_Ttlinspections)

Awesome, that did it! Thank you so much for that. 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 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.