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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
nakul555
Frequent Visitor

Need help to calculate defect rate over months

I have 2 unrelated queries pulled from oracle as shown below. I need to calculate defect rate over months.

Each row in table one depicts one single defect on that date. So i would need (sum of all defects in a month)/(total sales in a month)  in a line chart over months. Please help.

 

Table 1
Unique identifierDate
598215/8/2019
584216/8/2019
666517/8/2019
778918/8/2019
56322/9/2019
12353/9/2019
75364/9/2019
75425/9/2019
36986/9/2019
55427/9/2019
22958/9/2019
96589/9/2019

 

Table 2
MonthsSales
Jun-196000
Jul-197000
Aug-198000
Sep-196000
Oct-198000
Nov-199000
Dec-197000
1 ACCEPTED SOLUTION
v-jayw-msft
Community Support
Community Support

Hi @nakul555 ,

 

Check the measure.

Measure = CALCULATE(SUM('Table'[Unique identifier]),FILTER('Table',FORMAT('Table'[Date],"YYYYMM")=FORMAT(SELECTEDVALUE('Table (2)'[Months]),"YYYYMM")))/SELECTEDVALUE('Table (2)'[Sales])

Result would be shown as below.

1.PNG 

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.

View solution in original post

5 REPLIES 5
v-jayw-msft
Community Support
Community Support

Hi @nakul555 ,

 

Check the measure.

Measure = CALCULATE(SUM('Table'[Unique identifier]),FILTER('Table',FORMAT('Table'[Date],"YYYYMM")=FORMAT(SELECTEDVALUE('Table (2)'[Months]),"YYYYMM")))/SELECTEDVALUE('Table (2)'[Sales])

Result would be shown as below.

1.PNG 

 

Best Regards,

Jay

Community Support Team _ Jay
If this post helps, then please consider Accept it as the solution
to help the other members find it.
amitchandak
Super User
Super User

@nakul555 , In the second table, create a date like this (based on the given format)

 

Date = "01-" & [Months] // Change data type to date.

Now create a common date table with months and join to date in both tables and use month from date table

To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s. Refer :radacad sqlbi My Video Series Appreciate your Kudos.

 

 

Please provide your feedback comments and advice for new videos
Tutorial Series Dax Vs SQL Direct Query PBI Tips
Appreciate your Kudos.

How do I code the formula for calculating defect rate?

@nakul555 , Try measure like

 

divide(count(Table[Unique identifier]), sum(Table2[Sales]]))

@amitchandak  Tried that, but its returning 0. I created a relationship between all months from 3 tables. Is that correct?

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

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

MayPowerBICarousel

Power BI Monthly Update - May 2024

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

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.