Don't miss your chance to take the Fabric Data Engineer (DP-700) exam on us!
Learn moreWe've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now
Hello,
I've been wracking my brain around how to best solve this question but haven't came up with something acceptable.
I have 38000 rows of data that documents each time a test is performed and the result of that test. A Test Subject belongs to a Department. A Test Subject may have more than one Test Case, and if a Test Case fails, it will be retested until it passes. I'm looking for a way to know how many test subjects pass a test the first time vs those that needed to be retested.
Thank you for any insight you can provide!
Sample data: (simulated due to sensitivity)
| Department | Test Subject | Test Case | Timestamp | User | Status |
| 1 | 44262 | 100110 | 17/03/2020 | Bill | Passed |
| 2 | 46161 | 100111 | 17/03/2020 | Paige | Failed |
| 1 | 45886 | 100109 | 17/03/2020 | Rob | Passed |
| 1 | 45886 | 100110 | 17/03/2020 | Rob | Failed |
| 2 | 46161 | 100111 | 18/03/2020 | Bob | Ready to Retest |
| 1 | 45886 | 100110 | 18/03/2020 | Bob | Ready to Retest |
| 1 | 45886 | 100110 | 20/03/2020 | Paige | Passed |
| 2 | 46161 | 100111 | 20/03/2020 | Bill | Passed |
Solved! Go to Solution.
Hi @Anonymous
as assumed, there may be two cases:
one:
Measure =
VAR mindate =
CALCULATE (
MIN ( 'Table'[Timestamp] ),
ALLEXCEPT (
'Table',
'Table'[Test Subject],
'Table'[Test Case]
)
)
RETURN
CALCULATE (
MAX ( 'Table'[Status] ),
FILTER (
'Table',
'Table'[Timestamp] = mindate
)
)
Measure 2 =
VAR mincase =
CALCULATE (
MIN ( 'Table'[Test Case] ),
ALLEXCEPT (
'Table',
'Table'[Test Subject]
)
)
RETURN
CALCULATE (
[Measure],
FILTER (
'Table',
'Table'[Test Case] = mincase
)
)
pass a test the first time = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure 2]="Passed"))
needed to be retested = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure]="Failed"))
another:
Measure 3 =
IF (
FIND (
"Failed",
CONCATENATEX (
ALLEXCEPT (
'Table',
'Table'[Test Subject]
),
[Measure],
","
),
1,
0
) >= 1,
"Failed",
"Passed"
)
pass a test the first time2 = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure 3]="Passed"))
needed to be retested 2 = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure 3]="Failed"))
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous
as assumed, there may be two cases:
one:
Measure =
VAR mindate =
CALCULATE (
MIN ( 'Table'[Timestamp] ),
ALLEXCEPT (
'Table',
'Table'[Test Subject],
'Table'[Test Case]
)
)
RETURN
CALCULATE (
MAX ( 'Table'[Status] ),
FILTER (
'Table',
'Table'[Timestamp] = mindate
)
)
Measure 2 =
VAR mincase =
CALCULATE (
MIN ( 'Table'[Test Case] ),
ALLEXCEPT (
'Table',
'Table'[Test Subject]
)
)
RETURN
CALCULATE (
[Measure],
FILTER (
'Table',
'Table'[Test Case] = mincase
)
)
pass a test the first time = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure 2]="Passed"))
needed to be retested = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure]="Failed"))
another:
Measure 3 =
IF (
FIND (
"Failed",
CONCATENATEX (
ALLEXCEPT (
'Table',
'Table'[Test Subject]
),
[Measure],
","
),
1,
0
) >= 1,
"Failed",
"Passed"
)
pass a test the first time2 = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure 3]="Passed"))
needed to be retested 2 = CALCULATE(DISTINCTCOUNT('Table'[Test Subject]),FILTER('Table','Table'[Measure 3]="Failed"))
Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
This is exactly what I'm looking for. Thank you very much for your help, @v-juanli-msft. You just made my life a whole lot easier!
@Anonymous , Create a rank on Date under test subject. Then Rank =1 and Status =pass you are looking for
Create a column Rank, refer first article
For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/367415
Please Watch/Like/Share My webinar on Time Intelligence: https://community.powerbi.com/t5/Webinars-and-Video-Gallery/PowerBI-Time-Intelligence-Calendar-WTD-YTD-LYTD-Week-Over-Week/m-p/1051626#M184
My Your Tube Tips at: https://www.youtube.com/playlist?list=PLPaNVDMhUXGYrm5rm6ME6rjzKGSvT9Jmy
Appreciate your Kudos.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 56 | |
| 40 | |
| 36 | |
| 20 | |
| 18 |
| User | Count |
|---|---|
| 73 | |
| 73 | |
| 38 | |
| 35 | |
| 26 |