Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have an inspection dataset similar to the below.
| ID | Date | Result |
| 1 | 01/01/2022 | Pass |
| 1 | 02/01/2022 | Fail |
| 2 | 01/01/2022 | Pass |
| 2 | 02/01/2022 | Pass |
| 2 | 03/01/2022 | Fail |
I want to create a measure which can track the following:
Many thanks 🙂
Solved! Go to Solution.
Hi @Anonymous ,
I modify these measures, please try them:
Datediff =
VAR startdate =
CALCULATE ( MIN ( 'Table'[Date] ), 'Table'[Result] = "Pass" )
VAR enddate =
CALCULATE (
MIN ( 'Table'[Date] ),
'Table'[Result] = "Fail",
'Table'[Date] >= startdate
)
RETURN
DATEDIFF ( startdate, enddate, DAY ) + 0Total recieve Pass then Fail = SUMX ( VALUES ( 'Table'[ID] ), [recieve Pass then Fail] )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Please try the following formula:
Datediff =
VAR startdate =
CALCULATE ( MIN ( 'Table'[Date] ), 'Table'[Result] = "Pass" )
VAR enddate =
CALCULATE (
MIN ( 'Table'[Date] ),
'Table'[Result] = "Fail",
'Table'[Date] >= startdate
)
RETURN
DATEDIFF ( startdate, enddate, DAY )Average time = AVERAGEX ( VALUES ( 'Table'[ID] ), [Datediff] )CountResultPerID =
CALCULATE (
DISTINCTCOUNT ( 'Table'[Result] ),
ALLEXCEPT ( 'Table', 'Table'[ID] )
)only recieve Pass =
CALCULATE (
DISTINCTCOUNT ( 'Table'[ID] ),
FILTER ( 'Table', 'Table'[Result] = "Pass" && [CountResultPerID] = 1 )
)recieve Pass then Fail =
VAR Firstday =
CALCULATE ( MIN ( 'Table'[Date] ), ALLEXCEPT ( 'Table', 'Table'[ID] ) )
RETURN
CALCULATE (
DISTINCTCOUNT ( 'Table'[ID] ),
FILTER (
'Table',
'Table'[Date] = Firstday
&& 'Table'[Result] = "Pass"
&& [CountResultPerID] = 2
)
)
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi,
Thanks for your response. I have added all measures into my PBIX file and are recieving some errors.
Looking at ID 1796 in particalar I have the below data.
| ID | Date | Result |
| 1796 | 15/12/2021 | Pass |
| 1796 | 08/12/2021 | Pass |
| 1796 | 01/12/2021 | Pass |
| 1796 | 24/11/2021 | Pass |
| 1796 | 17/11/2021 | Pass |
| 1796 | 10/11/2021 | Pass |
| 1796 | 03/11/2021 | Pass |
| 1796 | 27/10/2021 | Pass |
| 1796 | 20/10/2021 | Pass |
| 1796 | 13/10/2021 | Pass |
| 1796 | 06/10/2021 | Pass |
| 1796 | 29/09/2021 | Pass |
| 1796 | 22/09/2021 | Pass |
| 1796 | 15/09/2021 | Pass |
| 1796 | 08/09/2021 | Pass |
| 1796 | 01/09/2021 | Pass |
| 1796 | 25/08/2021 | Fail |
I am seeing the below results which is not correct as this specific ID has a fail.
Any ideas?
Hi @Anonymous ,
I modify these measures, please try them:
Datediff =
VAR startdate =
CALCULATE ( MIN ( 'Table'[Date] ), 'Table'[Result] = "Pass" )
VAR enddate =
CALCULATE (
MIN ( 'Table'[Date] ),
'Table'[Result] = "Fail",
'Table'[Date] >= startdate
)
RETURN
DATEDIFF ( startdate, enddate, DAY ) + 0Total recieve Pass then Fail = SUMX ( VALUES ( 'Table'[ID] ), [recieve Pass then Fail] )
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Please provide sanitized sample data that fully covers your issue. Your scenario 2 is not covered.
Please show the expected outcome based on the sample data you provided.
Hi,
Thanks for your response. Unfortunetely due to company confidentity I can only supply a sample dataset.
| ID | Date | Result |
| 1 | 01/01/2022 | Pass |
| 1 | 02/01/2022 | Fail |
| 2 | 01/01/2022 | Pass |
| 2 | 02/01/2022 | Pass |
| 2 | 03/01/2022 | Fail |
| 3 | 01/02/2022 | Pass |
Based upon the above dataset I would see the below outcomes for each scenario.
1. Average time it takes to fail after recieving a pass as the first result = 1.5 days
2. Count of distinct ID's that only ever recieve a Pass = 1
3. Count of distinct ID's that recieve a Pass as their first result then a Fail any time after the first Pass = 2
Hope this helps.
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 37 | |
| 33 | |
| 32 | |
| 29 |
| User | Count |
|---|---|
| 130 | |
| 88 | |
| 82 | |
| 68 | |
| 64 |