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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
Solution Sage
Solution Sage

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
Solution Sage
Solution Sage

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors