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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Count Yes/No responses over 3 day time period. Return "Pass" if 3 consecutive 'Yes'. 'Fail' if not.

I have a table for test results with columns as follows:

 

Test Date / Metric / Source Value / Target Value / Difference / Pass/Fail 

 

A test passes if the difference is 0. There are multiple tests over time for the same metric. 

 

I want to count if a metric has 'Pass' in the Pass/Fail column consecutively every 3 days. Return a 'Pass' in a new column if so. 'Fail' if not. 

 

I'm a Power BI newbie, any help would be appreciated!

 

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

First go to query editor >add an index column,

Then create 4 columns as below:

 

Column = IF(SEARCH("Fail",'Table'[Pass/Fail],,0)=0,0,1)
Column 2 = 
var pre1=CALCULATE(MAX('Table'[Test Run Date]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1))
var pre2=CALCULATE(MAX('Table'[Test Run Date]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-2))
Return
IF(pre1=BLANK()||pre2=BLANK(),BLANK(),IF(pre1=DATEADD('Table'[Test Run Date],1,DAY)&&pre2=DATEADD('Table'[Test Run Date],2,DAY),1,BLANK()))
Column 3 = 
var pre1=CALCULATE(MAX('Table'[Pass/Fail]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1))
var pre2=CALCULATE(MAX('Table'[Pass/Fail]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-2))
Return
IF(pre1=BLANK()||pre2=BLANK(),BLANK(),IF(pre1='Table'[Pass/Fail]&&pre2='Table'[Pass/Fail],1,BLANK()))
Column 4 = IF('Table'[Column 2]=1&&'Table'[Column 3]=1,'Table'[Pass/Fail],BLANK())

 

Finally you will see:

 

Annotation 2020-03-18 095302.png

 

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
 

 

 

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

Can you share sample data and sample output.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

for your perusalfor your perusal

Anonymous
Not applicable

Ignore Attribute columns.

 

As you can see, there can be multiple tests for the same metric on each day. I want to count if all those tests 'Pass' over 3 days.

Hi  @Anonymous ,

 

While analyzing your data,I found that there aren't 3 consecutive days in it,so would you pls check and update the data?

 

Annotation 2020-03-13 170131.png

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
Anonymous
Not applicable

See image. Ignore all 'Attribute' and 'UV?' columns.  There are around 2000 rows in this table.

 

for mybros2.PNG

Hi @Anonymous ,

 

First go to query editor >add an index column,

Then create 4 columns as below:

 

Column = IF(SEARCH("Fail",'Table'[Pass/Fail],,0)=0,0,1)
Column 2 = 
var pre1=CALCULATE(MAX('Table'[Test Run Date]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1))
var pre2=CALCULATE(MAX('Table'[Test Run Date]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-2))
Return
IF(pre1=BLANK()||pre2=BLANK(),BLANK(),IF(pre1=DATEADD('Table'[Test Run Date],1,DAY)&&pre2=DATEADD('Table'[Test Run Date],2,DAY),1,BLANK()))
Column 3 = 
var pre1=CALCULATE(MAX('Table'[Pass/Fail]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-1))
var pre2=CALCULATE(MAX('Table'[Pass/Fail]),FILTER('Table','Table'[Index]=EARLIER('Table'[Index])-2))
Return
IF(pre1=BLANK()||pre2=BLANK(),BLANK(),IF(pre1='Table'[Pass/Fail]&&pre2='Table'[Pass/Fail],1,BLANK()))
Column 4 = IF('Table'[Column 2]=1&&'Table'[Column 3]=1,'Table'[Pass/Fail],BLANK())

 

Finally you will see:

 

Annotation 2020-03-18 095302.png

 

For the related .pbix file,pls click here.

 

Best Regards,
Kelly
Did I answer your question? Mark my post as a solution!
 

 

 

@Anonymous , where is the test completion date. I think not clear to me yet.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.