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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors