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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Gschalk87
Frequent Visitor

Help on measure formula

Hello All,

 

I am having some trouble figuring out how to make a measure work correctly, I am trying to get the count of final failures in a process.

 

i have data in a table that records part number, serial number, result, pass(65) or fail (105). seems simple enough to use

Final Reject = 
CALCULATE(DISTINCTCOUNT(StationEventHist[PartSerialNbr]),StationEventHist[EventID]=VALUE(105))

however the process is structured where a serial number can fail multiple times for various reasons, get repaired and retested and then get a good result, leaving me counting rejects that were fixed or corrected

 

example:

 

SN     Result

123     fail

123     fail

123     fail

123     pass

'

my formula yeilds final reject = 3 and final accept = 1

The goal is to have final reject count = 0 and final accept count = 1

 

Thank you!

 

 

1 ACCEPTED SOLUTION

Another approach that woudl work even If you don't have the date field suggested by jthomson.

 

You could staging tables of serial numbers that have passed and failed using summarize with filters to capure only passing adn failing NS's respectively and include other calculated or relevant columns as needed,

 

Passing SN = CALCULATETABLE(SUMMARIZE('StationEventHist',StationEventHist[PartSerialNbr]),'StationEventHist[EventID]<>65)

Reject SN = CALCULATETABLE(SUMMARIZE('StationEventHist',StationEventHist[PartSerialNbr]),'StationEventHist[EventID]<>105)

 

Then update you mesures to calculate form these tables and join the tables in your model by SN so any other filters you apply would work correctly.

 

 

View solution in original post

4 REPLIES 4
v-jiascu-msft
Employee
Employee

Hi @Gschalk87,

 


Can you mark the proper answer as a solution please?

 

Best Regards,

Dale

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

sorry for delay! ended up digging into the current SQL Statement flow and folling its logic and the idea suggested, if it dosnt have a good test record, it must have a bad record. this matches the current system, but i may look into running stored procedure to use the exact method everyone on site is used to seeing.

 

Thank you for your help!

jthomson
Solution Sage
Solution Sage

There's a few ways you could look at this depending on how exactly your data model works - if each SN can only pass once, you could do a distinct count of all the serial numbers, then do a count of the number of rows that have a result of pass and take one from the other, or if there's some sort of date/time field with each row, you could play with filters to just look at the most recent instance for any given SN (should be easy to search for the correct syntax)

Another approach that woudl work even If you don't have the date field suggested by jthomson.

 

You could staging tables of serial numbers that have passed and failed using summarize with filters to capure only passing adn failing NS's respectively and include other calculated or relevant columns as needed,

 

Passing SN = CALCULATETABLE(SUMMARIZE('StationEventHist',StationEventHist[PartSerialNbr]),'StationEventHist[EventID]<>65)

Reject SN = CALCULATETABLE(SUMMARIZE('StationEventHist',StationEventHist[PartSerialNbr]),'StationEventHist[EventID]<>105)

 

Then update you mesures to calculate form these tables and join the tables in your model by SN so any other filters you apply would work correctly.

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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