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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
KarmenN
Regular Visitor

DAX calculation

Hello!

 

I am trying to find out how to calculate "rate for not OK products", so I created a sample data.

 

I have 2 main tables:

1)All produced orders, together with production operations, date, qty

2)Reported not OK products together with operation (where defect was found), date, qty

 

To connect date between these tables, I have created:

1)Date table

2)List with all manufacturing orders

3)List with all possible production operations

 

KarmenN_0-1664912992833.png

I also made 2 tables.
First one shows how many pcs reported as "not OK products" in each operation for each manufacturing order. Second one shows how many pcs produced in each operation in total:

KarmenN_1-1664913397071.png

Now I would like to calculate "rate for not OK products" for each MO in each operation. 

For example order 3447 

*100pcs reported in total in pre.test operation, - reported as "Not OK", rate should be 0/100*100=0%

*90pcs reported in EOL operation, 12pcs reported as "not ok", rate should be 12/90*100=13,33%

 

Calculation itself is very easy, but how to do it with DAX in PowerBI, so I would get correct value for each operation?

 

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION
MarkLaf
Super User
Super User

Make sure you use the fields from your dimension tables ('Description1', 'list of allMO-s') and then you should be able to drop the below measure in to get what you want (if I'm understanding your requirements).

rate for not OK products =
DIVIDE( COUNTROWS( 'QA data' ), COUNTROWS( 'tehtud MO-d' ) )

Note that this is just counting the related rows. If you have value columns in 'QA data' and/or 'tehtud MO-d' that you want to sum, then replace the COUNTROWS on a table with SUM on a column (e.g., SUM( 'QA data'[Total_QTY] ) )

 

To get the percent formatting, use the measure formatting settings:

MarkLaf_0-1664917525142.png

 

View solution in original post

1 REPLY 1
MarkLaf
Super User
Super User

Make sure you use the fields from your dimension tables ('Description1', 'list of allMO-s') and then you should be able to drop the below measure in to get what you want (if I'm understanding your requirements).

rate for not OK products =
DIVIDE( COUNTROWS( 'QA data' ), COUNTROWS( 'tehtud MO-d' ) )

Note that this is just counting the related rows. If you have value columns in 'QA data' and/or 'tehtud MO-d' that you want to sum, then replace the COUNTROWS on a table with SUM on a column (e.g., SUM( 'QA data'[Total_QTY] ) )

 

To get the percent formatting, use the measure formatting settings:

MarkLaf_0-1664917525142.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.