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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Shannyn
New Member

How to remove duplicate rows of lesser value

Hi All, 

 

Hoping you can help.

I am trying to remove rows from a file where there is a duplicate Product ID, but I wish to remove the row that contains a 'Sales' amount of the lesser value.

 

Any suggestions would be greatly appreciated

 

Please see snip below

 

Shannyn_0-1665394685548.png

 

Cheers!

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

Hi , @Shannyn 

Based on your description, you want to keep the record of the largest [Sales] of the duplicate [Product_ID].Right?

It will be easier in Power Query Editor, Here are the steps you can refer to :

(1)This is my test data :

vyueyunzhmsft_0-1665454597250.png

(2)We can click "Insert Step After" to create a step in the query and enter M language:

vyueyunzhmsft_1-1665454626245.png

= Table.Group(#"Changed Type" , "Product_ID" , {"test",(x)=> Table.Sort(x,{"Sales",1}){0}   }    )

The #"Changed Type"  is your last step name.The result is as follows:

vyueyunzhmsft_2-1665454872513.png

(3)Then we can expand the "Record" and we will meet your need:

vyueyunzhmsft_3-1665454932270.png

The result is as follows:

vyueyunzhmsft_4-1665454947446.png

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

 

View solution in original post

3 REPLIES 3
Ashish_Mathur
Super User
Super User

Hi,

Share some data to work with and show the expected result.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-yueyunzh-msft
Community Support
Community Support

Hi , @Shannyn 

Based on your description, you want to keep the record of the largest [Sales] of the duplicate [Product_ID].Right?

It will be easier in Power Query Editor, Here are the steps you can refer to :

(1)This is my test data :

vyueyunzhmsft_0-1665454597250.png

(2)We can click "Insert Step After" to create a step in the query and enter M language:

vyueyunzhmsft_1-1665454626245.png

= Table.Group(#"Changed Type" , "Product_ID" , {"test",(x)=> Table.Sort(x,{"Sales",1}){0}   }    )

The #"Changed Type"  is your last step name.The result is as follows:

vyueyunzhmsft_2-1665454872513.png

(3)Then we can expand the "Record" and we will meet your need:

vyueyunzhmsft_3-1665454932270.png

The result is as follows:

vyueyunzhmsft_4-1665454947446.png

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

 

 

 

amitchandak
Super User
Super User

@Shannyn , I think you can manage that in a  measure

 

sumx(Values(Table[Product]), calculate(Max(Table[Value])) )

 

or create a flag measure

 

if([Value] = maxx(filter(Table, [Product] =earlier([Product]) ), [Value],1,0)

 

filter for 1

 

Power BI DAX- Earlier, I should have known Earlier: https://youtu.be/CVW6YwvHHi8

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.