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
webportal
Impactful Individual
Impactful Individual

Remove symmetrical records with Power Query

Is there a way to remove the yellow records with Power Query?

They are errors and I need to get rid of them:

webportal_0-1619533898144.png

 

The process could be something like:

  1. Filter the table to retrieve the rows containing only the current "CustomerID"
  2. Check the Sales. Is there any value with -Sales?

And then delete those rows.

 

This table contains many other Customer ID's - this is just a sample.

1 ACCEPTED SOLUTION
v-yalanwu-msft
Community Support
Community Support

Hi @webportal  ,


According to you description, you could Use M language in power query, as follows:

v-yalanwu-msft_0-1620092625434.png

let

#"Changed Type" = Table.TransformColumnTypes(Source,{{"CustomerID", Int64.Type}, {"Sales", Int64.Type}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type", "Original", each Number.ToText([CustomerID]) &" "& Number.ToText( [Sales])),
#"Added Custom" = Table.AddColumn(#"Added Custom1", "Opposite", each Number.ToText([CustomerID]) &" "& Number.ToText( [Sales]*-1)),
#"Added Custom2" = Table.AddColumn(#"Added Custom", "Flag", each if List.Contains(#"Added Custom"[Original],[Opposite]) then "" else 1),
#"Filtered Rows" = Table.SelectRows(#"Added Custom2", each [Flag] <> null and [Flag] <> ""),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Original", "Opposite", "Flag"})
in
#"Removed Columns"

The final output is shown below:

v-yalanwu-msft_1-1620092639762.pngvsv-yalanwu-msft_2-1620092662734.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
#End Reply 2nd

View solution in original post

9 REPLIES 9
v-yalanwu-msft
Community Support
Community Support

Hi @webportal  ,


According to you description, you could Use M language in power query, as follows:

v-yalanwu-msft_0-1620092625434.png

let

#"Changed Type" = Table.TransformColumnTypes(Source,{{"CustomerID", Int64.Type}, {"Sales", Int64.Type}}),
#"Added Custom1" = Table.AddColumn(#"Changed Type", "Original", each Number.ToText([CustomerID]) &" "& Number.ToText( [Sales])),
#"Added Custom" = Table.AddColumn(#"Added Custom1", "Opposite", each Number.ToText([CustomerID]) &" "& Number.ToText( [Sales]*-1)),
#"Added Custom2" = Table.AddColumn(#"Added Custom", "Flag", each if List.Contains(#"Added Custom"[Original],[Opposite]) then "" else 1),
#"Filtered Rows" = Table.SelectRows(#"Added Custom2", each [Flag] <> null and [Flag] <> ""),
#"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Original", "Opposite", "Flag"})
in
#"Removed Columns"

The final output is shown below:

v-yalanwu-msft_1-1620092639762.pngvsv-yalanwu-msft_2-1620092662734.png


Best Regards,
Community Support Team_ Yalan Wu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
#End Reply 2nd

Ashish_Mathur
Super User
Super User

Hi,

Your question is not clear.  Why should the rows showing 222.83 and -222.83 not be deleted as well?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur 

Hi, yes. Those rows should also be deleted since they're simmetrical.

Sorry but i won't be able to help with this.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Vera_33
Resident Rockstar
Resident Rockstar

Hi @webportal 

 

If I understand correctly, you also need to remove the two rows with 222,83 and -222,83 for this Customer ID in the sample? And the rows you want to remove are always together? Can you provide some sample data in a format we can copy?

webportal
Impactful Individual
Impactful Individual

Exactly @Vera_33 

 

No, the rows aren't always together, they can be far away.

Hi @webportal 

 

I am asking do they appear as a pair like 222,83 and -222,83, or 222,83 can be far away with -222,83?

webportal
Impactful Individual
Impactful Individual

No, they don't always appear as a pair.

Sometimes they're far away.

ok, @webportal  have you tried the way from @v-yalanwu-msft ?

 

I've got anther 2 questions:

 

#1 does postive always come first in the pair? say  (222,83 and -222,83), 222,83 comes first?

 

#2 is it possible you have 222,83 and -222,83 and 222,83 for the same customer or 222,83 and 222,83 and -222,83?

 

Really need to observe the data and find out patterns

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.

Top Solution Authors