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
jrmax
Frequent Visitor

How to get and COUNT items tested excluding only the first test.

Hi guys, we have a table like the one below with multiple serials tested. We want to know how to create a measure for:
- All serial_numbers re-tested
- Count of Serial_numbers re-tested
- SUM of the column -TestDuration- for re-rest only

We got the First/Last items tested and -First Pass Yield- calculation, but we are now stuck on these new measures for re-tests.


Any advice will be appreciated.

 

Thank you!

JR

restest3.PNG

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @jrmax,

I think you can add a variable to get the first date from your table based on current category, then you can and add an if statement to compare current date and the first date and use this as condition in calculation formula.

If you confused about coding formula, please share some dummy data to test.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

5 REPLIES 5
v-shex-msft
Community Support
Community Support

Hi @jrmax,

I think you can add a variable to get the first date from your table based on current category, then you can and add an if statement to compare current date and the first date and use this as condition in calculation formula.

If you confused about coding formula, please share some dummy data to test.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

I found it !!, thank you @v-shex-msft, for the tip; a small piece of advice makes a huge difference. 

 

Here is the code that worked for me:

 

 

First Test Date In Timeframe =
// Returns the first test date in
// the current context.
IF( HASONEFILTER( 'Logs'[Serial_Number] ),
      var __serialN = SELECTEDVALUE( 'Logs'[Serial_Number] )
      var __firstTestDate =
                          MINX(
                               CALCULATETABLE(
                                               'Logs',
                                               'Logs'[Serial_Number] = __serialN,
                                               ALLSELECTED('Logs')
                                              ),
                                              'Logs'[testDateTime]
                              )
return
__firstTestDate


Retest Count In Timeframe =
// Returns the count of SNs retested
// in the current timeframe.
var __retestCountResult =
                          SUMX(
                               VALUES('Logs'[testDateTime]),
                               IF('Logs'[testDateTime]>[First Test Date In Timeframe],
                                  1,
                                  0
                                   )
                                )
return
       IF( __retestCountResult > 0, __retestCountResult )


Retest Time Duration in Timeframe =
// Returns the retest time duration of
// SNs.
var __retestDurationTime =
                          SUMX(
                                ALLSELECTED('Logs'),
                                IF('Logs'[testDateTime]>[First Test Date In Timeframe],
                                    VALUE('Logs'[testDuration]),
                                    0
                                   )
                                )
return
IF( __retestDurationTime > 0, FORMAT(__retestDurationTime,"HH:MM:SS" ))

 

 

Thank you, @v-shex-msft! Here is sample data; a formula will be helpful... thanks!!

 

CommentSerial_NumbertestDateTimetestDurationfinalTestResult
FirstTestSN089561111/11/2022 12:18:0302:19.1Fail
FirstTestSN073121411/11/2022 12:18:4802:19.4Fail
Re-testSN089561111/11/2022 12:21:2603:51.3Pass
Re-testSN073121411/11/2022 12:21:3605:02.5Fail
FirstTestSN044121211/11/2022 12:22:2903:50.9Fail
FirstTestSN042361211/11/2022 12:22:4003:50.9Fail
Re-testSN042361211/11/2022 12:23:4002:21.1Fail
Re-testSN042361211/11/2022 12:26:3403:51.8Pass
Re-testSN044121211/11/2022 12:27:0703:50.3Fail
Re-testSN073121411/11/2022 12:27:4703:54.7Pass

 

amitchandak
Super User
Super User

@jrmax ,The information you have provided is not making the problem clear to me. Can you please explain with an example.

Appreciate your Kudos.

Thank you @amitchandak 

 

EDITED adding a more context and picture: 

restest3.PNG

Given the previous table, a Retest is a SerialNo tested more than once, so in this case, SN200 and SN300 (with the red arrow) are considered retests.

 

We want to know how many retests were made, in this case it should be equal to: 4 and the SUM of column TestDuration

Thank you again!, we really appreciate any help on this.       

 

 

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.