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!Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!
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!
Solved! Go to 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:
For the related .pbix file,pls click here.
for your perusal
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?
See image. Ignore all 'Attribute' and 'UV?' columns. There are around 2000 rows in this table.
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:
For the related .pbix file,pls click here.
Vote for your favorite vizzies from the Power BI World Championship submissions!
If you love stickers, then you will definitely want to check out our Community Sticker Challenge!
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 58 | |
| 53 | |
| 40 | |
| 17 | |
| 16 |
| User | Count |
|---|---|
| 116 | |
| 105 | |
| 41 | |
| 34 | |
| 25 |