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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
grggmrtn
Post Patron
Post Patron

Remove duplicates without breaking query folding?

Is there a way to remove duplicates without breaking query folding? I need the folding (for incremental refresh), but I have a ton of duplicates (I go from 3 0378 271 rows to 10 472 after removing duplicates)...

7 REPLIES 7
Toddmcdermid
New Member

Use a Group By transform instead - that will fold on SQL data sources.

OPTIONAL - If you don't want an aggregate column added to the rowset (so you want it to behave functionally exactly like a remove duplicates), then edit the M that gets generated to remove the aggregate. For example, turn this:

= Table.Group(Source, {"Grouping Column 1","Grouping Column 2"}, {{"Count", each 1, type Int64}})

into this:

= Table.Group(Source, {"Grouping Column 1","Grouping Column 2"}, {})

amitchandak
Super User
Super User

@grggmrtn , how are you deleting duplicate as of now, power Query- delete duplicate ?

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Yeah, exactly.

Hi @grggmrtn ,

 

This can happen if the date ranges are set NOT up to as follows: [Date] >= RangeStart and [Date] < RangeEnd. Is your upper bound set to be equal to or less than or just less than?

Refer to this thread:

https://community.powerbi.com/t5/Desktop/Problem-with-incremental-refresh-on-power-bi-premium/td-p/7... 

 

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

Hi @V-lianl-msft thanks for the reply...

 

Your answer would make sense if I had actually set ranges, but I haven't gotten to setting the ranges yet, because query folding on my dataset breaks. The final step in my query (remove duplicates) breaks the folding.

 

So my question is, how can I remove the duplicates without breaking the folding?

@grggmrtn @amitchandak 

I could use this as well, did you ever find out how to do this? 

 

Table.Distinct() breaks the fold. How do we tell the servers to return a distinct list after all our previous steps? 

Never mind. Table.Distinct() only breaks the fold if you use it to remove duplicates from a subset of the tables columns, instead of the whole table. Using Table.Distinct() on the entire table does not break the query folding.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.