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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jaryszek
Post Prodigy
Post Prodigy

Check if next row in a list is different

Hi Guys, 

 

I have a list, "A, B, C" and want to check if B <> A and C <> B (so n <> n +1). 
Result should be {"B", "C"). 

I was trying with list.Accumulate, but I failed. It is possible with List.Accumulate or I  should use another function ?

 

Thanks!
Best,
Jacek

1 ACCEPTED SOLUTION

For List.Accumulate

= List.Accumulate({1..List.Count(list)-1}, {}, (s,c)=> if list{c} <> list{c-1} then s & {list{c}} else s)

View solution in original post

4 REPLIES 4
jaryszek
Post Prodigy
Post Prodigy

thank you!!

Vijay_A_Verma
Super User
Super User

Use this - Here list is your your list

List.RemoveNulls(List.Generate(()=>[x=null,i=0, c= List.Count(list)], each [i]<[c], each [i=[i]+1, x=if list{i} <> list{i-1} then list{i} else null, c=[c]], each [x]))

Thank you. 

So List.Accumulate is not possible? 

Best,
Jacek

For List.Accumulate

= List.Accumulate({1..List.Count(list)-1}, {}, (s,c)=> if list{c} <> list{c-1} then s & {list{c}} else s)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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