This is best Fabric, Power BI, SQL and AI community event. How do we know? The last event sold out! Save €200 with code FABCMTY200.
Register nowA new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.
Hi all,
I have a dataset in the format as follows:
| Week Number | Defect Code | Defect Count |
| 1 | 101 | 10 |
| 1 | 203 | 20 |
| 1 | 101 | 10 |
| 1 | 102 | 10 |
| 2 | 125 | 23 |
| 2 | 123 | 22 |
| 2 | 125 | 20 |
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!
Solved! Go to Solution.
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 )
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!
Check out the May 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 32 | |
| 25 | |
| 23 | |
| 22 | |
| 13 |
| User | Count |
|---|---|
| 61 | |
| 47 | |
| 27 | |
| 24 | |
| 19 |