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! Request now

Reply
Keegs27
New Member

Dividing a Sum by a Distinct Count, then applying a filter

I'm trying to visualise some data which is a sum of defect scores for a number of units that have been audited/assessed.  Each unit can have multiple defects (1 unit to many defects) and units are audited/assessed daily so the data is reviewed daily, weekly, monthly, quarterly, annually etc.  The defects are also associated with a department, respsonsible for creating it and therefore rectifying it.

 

I have the following measure:

 

AAA - Score divided by distinct count =
DIVIDE(
    SUM('Raw Data'[DefectScore]),
    DISTINCTCOUNT('Raw Data'[Unit ID])
)
 
I can then filter this to show a particular month.  This bit works and gives me the total sum of all defect scores for the month divided by the distinct count of units in the month e.g. if the defect scores is 100 and 50 units were audited/assessed then the averager score per unit is 2.0.
 
The next bit I want to be able to do is split this average scores into the contributions that each department made.  This is where it doesn't work.  I think applying the filter only takes into account the units that a specific department had a defect on and therefore the distinct count is incorrect (it should be a distinct count of all the units from the month but it is clearly a smaller number).
 I've put together the table below to help illustrate:
 
Unit IDDefect CodeDefect ScoreDepartment
Unit 1AB11Dept A
Unit 1AB25Dept B
Unit 1AB31Dept C
Unit 1AB41Dept A
Unit 2AB11Dept A
Unit 2AB31Dept C
Unit 3AB25Dept B
Unit 3AB71Dept C
Unit 3AB910Dept B
Unit 4AB81Dept D
Unit 5AB31Dept C
Unit 5AB41Dept A
 
Sum of the defect score = 29
Distinct unit count =5
Average score per unit = 5.8
 
I then apply a filter (or try to display using a pie chart) and I think the following happens:
 
Sum defect score for Dept A = 4
Distinct unit count = 5
Average score per unit = 0.8
 
However, Dept A only have defects on x3 distinct units and I think BI uses the number 3 as the distinct unit count and the answer I get is 4/3 = 1.33
 
Any help on how to stop the distinct count being reduced when the department filter is added would be useful. 
1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@Keegs27,

 

Try this measure:

 

AAA - Score divided by distinct count = 
DIVIDE (
    SUM ( 'Raw Data'[Defect Score] ),
    CALCULATE (
        DISTINCTCOUNT ( 'Raw Data'[Unit ID] ),
        ALL ( 'Raw Data'[Department] )
    )
)

 

DataInsights_0-1662935428655.png

---

DataInsights_1-1662935445040.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

2 REPLIES 2
Keegs27
New Member

That worked perfectly.  Thank you.

DataInsights
Super User
Super User

@Keegs27,

 

Try this measure:

 

AAA - Score divided by distinct count = 
DIVIDE (
    SUM ( 'Raw Data'[Defect Score] ),
    CALCULATE (
        DISTINCTCOUNT ( 'Raw Data'[Unit ID] ),
        ALL ( 'Raw Data'[Department] )
    )
)

 

DataInsights_0-1662935428655.png

---

DataInsights_1-1662935445040.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

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!

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