<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to remove duplicates based on sort order in Desktop</title>
    <link>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/277466#M123787</link>
    <description>&lt;P&gt;&amp;nbsp;Thank you so much Marcel! I have been struggling for days and googling crazy for a solution and you just solved my problem!!!&lt;/P&gt;</description>
    <pubDate>Fri, 13 Oct 2017 03:22:43 GMT</pubDate>
    <dc:creator>jadewind</dc:creator>
    <dc:date>2017-10-13T03:22:43Z</dc:date>
    <item>
      <title>How to remove duplicates based on sort order</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/130860#M55777</link>
      <description>&lt;P&gt;When loading the data I need to keep only the latest record.&lt;/P&gt;&lt;P&gt;I don't have a date to rely on to determine the latest record but I have a status, based on which I can sort in a somewhat chronological order.&lt;/P&gt;&lt;P&gt;&amp;nbsp;I thought I could&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;SPAN&gt;Associate a statusID to each status, making sure that the lowest the ID the latest the event&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Sort by statusID&lt;/SPAN&gt;&lt;/LI&gt;&lt;LI&gt;&lt;SPAN&gt;Remove duplicates&lt;/SPAN&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;Unfortunately it seems the sort order is not always respected,&lt;/P&gt;&lt;P&gt;I read that we should use the Table.Buffer() function before removing duplicates but that this could create performance issue.&lt;/P&gt;&lt;P&gt;It does indeed create performance issue. It works on a small scale but when I use this on the entire dataset the load process does not complete.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now I’m looking into using Table.SelectRows with a condition that would only return the row with the smallest statusID for each RequestID.&lt;/P&gt;&lt;P&gt;Something along the line of&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt; #"Latest Request" = Table.SelectRows(#"Previous Step", each (List.Max([RequestID]," statusID "))),&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But that does return a type incompatibility error&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 19:02:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/130860#M55777</guid>
      <dc:creator>fiveone</dc:creator>
      <dc:date>2017-02-21T19:02:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicates based on sort order</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/130923#M55808</link>
      <description>&lt;P&gt;My suggestion would be the following, illustrated by &lt;A href="https://youtu.be/GYCT0gtpiDQ" target="_self"&gt;this video&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I created some test data in Access just to verify if the code would allow for Query Folding &lt;EM&gt;(by rightclicking each step in the queries and check for the existence of Native Query).&lt;/EM&gt; They all did, so performance should be OK..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a query &lt;STRONG&gt;InputData&lt;/STRONG&gt; that just reads the data from Access. For this query, load is disabled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;let
    Source = Access.Database(File.Contents("C:\Users\Marcel\Documents\Forum bijdragen\Power BI Community\How to remove duplicates based on sort order.accdb"), [CreateNavigationProperties=true]),
    _Requests = Source{[Schema="",Item="Requests"]}[Data]
in
    _Requests&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a query &lt;STRONG&gt;MinStatusByRequestID&lt;/STRONG&gt; with input from query InputData that determines the minimum statusID for each RequestID using Group By on the Transform tab. Also for this query, load is disabled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;let
    Source = InputData,
    #"Grouped Rows" = Table.Group(Source, {"RequestID"}, {{"minStatus", each List.Min([statusID]), type number}})
in
    #"Grouped Rows"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I created a query &lt;STRONG&gt;FilteredData&lt;/STRONG&gt; that merges the previous 2 queries with an inner join. For this query, load is enabled.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;let
    Source = InputData,
    #"Merged Queries" = Table.Join(Source,{"RequestID", "statusID"},MinStatusByRequestID,{"RequestID", "minStatus"},JoinKind.Inner),
    #"Removed Columns" = Table.RemoveColumns(#"Merged Queries",{"minStatus"})
in
    #"Removed Columns"&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 20:49:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/130923#M55808</guid>
      <dc:creator>MarcelBeug</dc:creator>
      <dc:date>2017-02-21T20:49:44Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicates based on sort order</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/130962#M55825</link>
      <description>&lt;P&gt;Wow, thank you Marcel for taking the time to provide that detailed explanation and even making a video!&lt;/P&gt;&lt;P&gt;Leveraging grouping and merging is&amp;nbsp;brilliant.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Feb 2017 22:03:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/130962#M55825</guid>
      <dc:creator>osinquinvdm</dc:creator>
      <dc:date>2017-02-21T22:03:12Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicates based on sort order</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/277466#M123787</link>
      <description>&lt;P&gt;&amp;nbsp;Thank you so much Marcel! I have been struggling for days and googling crazy for a solution and you just solved my problem!!!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Oct 2017 03:22:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/277466#M123787</guid>
      <dc:creator>jadewind</dc:creator>
      <dc:date>2017-10-13T03:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicates based on sort order</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/377435#M171496</link>
      <description>&lt;P&gt;I have already uploaded a SQL data, how can I create a function to sort the column order and force de removing to follow the date sort? I dont know how to create the function...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is sad PBI dont "follow" the sort order to eliminate duplicates...&lt;/P&gt;</description>
      <pubDate>Fri, 16 Mar 2018 03:26:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/377435#M171496</guid>
      <dc:creator>acstaffa</dc:creator>
      <dc:date>2018-03-16T03:26:51Z</dc:date>
    </item>
    <item>
      <title>Re: How to remove duplicates based on sort order</title>
      <link>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/558275#M263163</link>
      <description>&lt;P&gt;We also had a similar problem. We found this solved our problem:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Sort data as required&lt;/P&gt;&lt;P&gt;2. Add index column starting at 1&lt;/P&gt;&lt;P&gt;3. Remove Duplicates&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The index column helps Power BI realise while removing duplicates that there is a specific order to the sorted data.&lt;/P&gt;</description>
      <pubDate>Thu, 01 Nov 2018 09:18:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/Desktop/How-to-remove-duplicates-based-on-sort-order/m-p/558275#M263163</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2018-11-01T09:18:21Z</dc:date>
    </item>
  </channel>
</rss>

