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

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

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.

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.

Top Solution Authors