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
jaryszek
Post Patron
Post Patron

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 Patron
Post Patron

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

Top Solution Authors
Top Kudoed Authors