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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Jo5hua22
Helper I
Helper I

Consecutive value being checked

Hi,

 

I would like your help to determine the below logic in the screenshot. Which is when there are consecutive values of "R" (more than 1 time) then the output should be displayed as "CHECK"

 

Jo5hua22_0-1645023590601.png

My current DAX code to determine CHECK/ NOT CHECK is given below

Output = 

var _seq = [S.No]
var _last = countx(filter(Table, Table[S.No] = _seq -1 && [KPI] = "R"),[S.No])
var _Next = countx(filter(Table, Table[S.No] = _seq +1 && [KPI] = "R"),[S.No])
return
Switch(True() ,
[KPI] = "R" && isblank(_last) && isblank(_next) , "No Check",
[KPI] = "R" && not(isblank(_last)) && isblank(_next) , "Check",
blank())

 

@amitchandak 

1 ACCEPTED SOLUTION
Jo5hua22
Helper I
Helper I

I found the answer

 

Output = 

var _seq = [S.No]
var _last = countx(filter(Table, Table[S.No] = _seq -1 && [KPI] = "R"),[S.No])
var _Next = countx(filter(Table, Table[S.No] = _seq +1 && [KPI] = "R"),[S.No])
return
Switch(True() ,
[KPI] = "R" && isblank(_last) && isblank(_next) , "No Check",
[KPI] = "R" &&

((not(isblank(_last)) && isblank(_next))||(not(isblank(_last)) && not(isblank(_next))))

, "Check",
blank())

View solution in original post

6 REPLIES 6
Jo5hua22
Helper I
Helper I

I found the answer

 

Output = 

var _seq = [S.No]
var _last = countx(filter(Table, Table[S.No] = _seq -1 && [KPI] = "R"),[S.No])
var _Next = countx(filter(Table, Table[S.No] = _seq +1 && [KPI] = "R"),[S.No])
return
Switch(True() ,
[KPI] = "R" && isblank(_last) && isblank(_next) , "No Check",
[KPI] = "R" &&

((not(isblank(_last)) && isblank(_next))||(not(isblank(_last)) && not(isblank(_next))))

, "Check",
blank())

Jo5hua22
Helper I
Helper I

@tamerj1 @amitchandak 
Can you please help me out?

tamerj1
Super User
Super User

It depends. What the other filters? Certin values for other colums? Can you send sample file?

Please find more detailed information. Basically if I know how to add filters in a Lookup inside an IF condition, I can solve it.

 

Jo5hua22_0-1645027661559.png

 

tamerj1
Super User
Super User

This calculated column should work:
Output =
IF (
Table[KPI] = "R",
IF (
LOOKUPVALUE ( Table[KPI], Table[S.No], Table[S.No] - 1 ) = "R",
"Check"
)
)

If ok, please consider marking my reply as accepted. Thank you!

Hi @tamerj1 

 

Thanks for the help. 

If I need more filters because I have a dataset with 2M rows, then where can I add the filter in your above DAX code?

 

Thanks in advance

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.