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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
anshpalash
Helper II
Helper II

Division Calculation by Week Number

Hi all,

 

I have a dataset in the format as follows:

Week NumberDefect CodeDefect Count
110110
120320
110110
110210
212523
212322
212520

 

I am trying to calculate defect rate for a particular defect code by week. For example, the defect rate would be the total defect counts for that particular defect code divided by the total defect counts in that week. I want to plot a line graph where the axis would be week number, values would be defect rate and legend would be defect code. 

For example, in this case, defect rate for defect code 101 for week 1 would be (10+10)/(10+20+10+10) = 20/50 = 40%

 

Can anybody please guide me on how I can achieve similar calculation as above? Thank you!

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

Create a measure as below

Defect Rate =
var currentCodeDefects = CALCULATE( SUM('Table'[Defect count]) )
var totalDefects = CALCULATE( SUM('Table'Defect count]), REMOVEFILTERS('Table'[Defect code]) )
return DIVIDE( currentCodeDefects, totalDefects )

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

Create a measure as below

Defect Rate =
var currentCodeDefects = CALCULATE( SUM('Table'[Defect count]) )
var totalDefects = CALCULATE( SUM('Table'Defect count]), REMOVEFILTERS('Table'[Defect code]) )
return DIVIDE( currentCodeDefects, totalDefects )

Thank you!

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.