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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Dicken
Continued Contributor
Continued Contributor

Power Query; List Remove / Matching Item

Hi, 
Can someone tell me if there is any practtical difference between  List.RemvoveItems and RemoveMatchinItems; 

example ; 

 

= [
alist = {"a","a","b","c","d","d","d","e","e","f","g"} ,
blist = { "a","d","e"} ,
matchitem = List.RemoveMatchingItems( alist, blist) ,
removeitem = List.RemoveItems( alist , blist )
]

I can't see that this is, i have seen things saying they treat duplicates differently but I can't get a reslt to show  this out? 

Richad. 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

List.RemoveMatchingItems is more flexible as it allows you to override the matching criteria.

View solution in original post

8 REPLIES 8
lbendlin
Super User
Super User

List.RemoveMatchingItems is more flexible as it allows you to override the matching criteria.

Dicken
Continued Contributor
Continued Contributor

re remvoe one only ; I have come up with ; 

let alist = {"a".."d","g","f","d","d","f","g","e"} ,

val = {"d","f","g"} ,

pos = List.Accumulate( val , {}, (s,c)=> s & { List.PositionOf( alist , c )} ),

newpos = List.Difference( {0..List.Count( alist)-1 } , pos )

in
List.Transform( newpos, (x)=> alist {x} )

I don't think I needed accumulate, as it lookslike there's and occurrnce first. 

what is your expected result?

Dicken
Continued Contributor
Continued Contributor

just to remove  a value a given number of times;  
so I was trying for what  list difference ; 
List.Difference(
{"a","a","a","b","b","b"} , {"a","a","b"} )    so    "a","b""b"

I think you are mixing up concepts.  Lists are collections of INDEPENDENT items. Items in a list do not know what their neighbors are.  Sounds more like you want to do string replacements.

Dicken
Continued Contributor
Continued Contributor

No I want to specify the number of times I remvoved Items from a list 
so if  I had a list { "a", "a","b","b","b","c","c","c"} and wanted to remove 
  "a" and "c", but I want to remove 2 a's and 1 c , I was just looking for an alternative to 
difference; 
= let alist =
{ "a","a","a","a","b","b","b","c","c","c"} ,
blist =
{ "a", "a", "c"} in
List.Difference( alist, blist ) 

 

That seems to give you the desired result, no?

 

lbendlin_0-1743765009849.png

 

Dicken
Continued Contributor
Continued Contributor

When you say override, could you give an example as I'm not sure what you mean unless 
you mean the equation criteria, ? 
Also is there a way to remove just a specifice number of items so if I have { "a","a","a","b","c"} 
and just wanted to remvoe 1 "a"?  I am working on this so If succeed I will show . 

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.