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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
stribor45
Post Prodigy
Post Prodigy

Remove some records from the table

I am having some troubles accomplishing following. If i have same id but the countries are different I want to keep country that is not Canada. 

 

I have table 

 

codecountry
11111Canada
11111Albania
22222Canada
33333Canada
33333Belgium
33333Canada
33333Belgium
44444Canada
44444Canada
44444Canada

 

And I need to get here. How would I do this?

 

codecountry
11111Albania
22222Canada
33333Belgium
44444Canada
2 ACCEPTED SOLUTIONS
Omid_Motamedise
Super User
Super User

Se this solution

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMgQBJR0l58S8xJREpVgdhJBjTlJiXiZEzAgEUJUZgwB2IafUnPTM0lxSlJmAAKoyIoRiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [code = _t, country = _t]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([country] <> "Canada"))&Source,
    #"Removed Duplicates" = Table.Distinct(#"Filtered Rows", {"code"})
in
    #"Removed Duplicates"

If my answer helped solve your issue, please consider marking it as the accepted solution.

View solution in original post

Hi @stribor45 ,

The answer provided by @Omid_Motamedise  @AlienSx  has resolved your issue? If so, kindly mark the helpful reply as the accepted solution. This will help other community members with similar concerns find solutions more efficiently.
Thank you for your cooperation!"

View solution in original post

6 REPLIES 6
Omid_Motamedise
Super User
Super User

Se this solution

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMgQBJR0l58S8xJREpVgdhJBjTlJiXiZEzAgEUJUZgwB2IafUnPTM0lxSlJmAAKoyIoRiAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [code = _t, country = _t]),
    #"Filtered Rows" = Table.SelectRows(Source, each ([country] <> "Canada"))&Source,
    #"Removed Duplicates" = Table.Distinct(#"Filtered Rows", {"code"})
in
    #"Removed Duplicates"

If my answer helped solve your issue, please consider marking it as the accepted solution.

Hi @stribor45 ,

The answer provided by @Omid_Motamedise  @AlienSx  has resolved your issue? If so, kindly mark the helpful reply as the accepted solution. This will help other community members with similar concerns find solutions more efficiently.
Thank you for your cooperation!"

stribor45
Post Prodigy
Post Prodigy

can this be adjusted so instead of removing the records just say no if its to be removed and yes if it is to be kept

AlienSx
Super User
Super User

Table.Group(Source, "code", {"country", (x) => List.Skip(x[country], (c) => c = "Canada"){0}? ?? "Canada"})

Works great. what does this code do

 

{0}? ?? "Canada"

M operators 

?: The item-access-expression also supports the form x{y}?, which returns null when position (or match) y does not exist in list or table x. If there are multiple matches for y, an error is still raised.

?? : Coalesce operator 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.