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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Jo5hua22
Helper I
Helper I

Calculate if a value is repeated or not in a sequential manner

Hi

 

I would like to know the DAX command to determine if the next row has the same value as the current row. Can  you please help me out? I have provided an example for better explanation

 

Example:

Jo5hua22_0-1644936560898.png

 

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@Jo5hua22 , A new column

 


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())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

tamerj1
Super User
Super User

Hi @Jo5hua22 

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

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

View solution in original post

4 REPLIES 4
tamerj1
Super User
Super User

Hi @Jo5hua22 

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

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

amitchandak
Super User
Super User

@Jo5hua22 , A new column

 


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())

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

I tried your code but I am getting blank columns as the output. Can you share the pbi file that you did?

@Jo5hua22 ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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