<?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: Custom sorting for calculated table (circular error) in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-sorting-for-calculated-table-circular-error/m-p/3997631#M155460</link>
    <description>&lt;P&gt;Wow thank you, that must help a lot of people. Unfortunately I'm working with a calculated table. But I'll try to add the column to the original source table and get back to you.&lt;/P&gt;</description>
    <pubDate>Tue, 18 Jun 2024 06:59:44 GMT</pubDate>
    <dc:creator>Joris_NL</dc:creator>
    <dc:date>2024-06-18T06:59:44Z</dc:date>
    <item>
      <title>Custom sorting for calculated table (circular error)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-sorting-for-calculated-table-circular-error/m-p/3996447#M155303</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a calculated table, in which I want the NAME column (all unique) to sort by CATEGORY first, and then sorted alphabetically second. Like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;NAME&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;CATEGORY Nr.&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;*My custom sorting column*&amp;nbsp; &amp;nbsp;&lt;/TD&gt;&lt;TD&gt;(The desired sorting result, based on custom sorting column )&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;A&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1001&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;first position&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;B&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;2003&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;third&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;C&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;1002&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;second&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;D&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;3&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;3004&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;fourth&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;E&lt;/TD&gt;&lt;TD&gt;4&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;4006&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;sixth&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;F&lt;/TD&gt;&lt;TD&gt;3&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;3005&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;fifth&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I managed to make the output for the custom sorting column:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;My custom sorting column = 
RANKX ( 'Table' ; 'Table'[NAME] ; ; ASC )
+
( 1000 * 'Table'[CATEGORY Nr.] )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I can't use this column to sort NAME! This gives a circular dependancy error. So the order of the names is used for the RANKX function, which is then used to order the names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any suggestions?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 15:20:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-sorting-for-calculated-table-circular-error/m-p/3996447#M155303</guid>
      <dc:creator>Joris_NL</dc:creator>
      <dc:date>2024-06-17T15:20:12Z</dc:date>
    </item>
    <item>
      <title>Re: Custom sorting for calculated table (circular error)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-sorting-for-calculated-table-circular-error/m-p/3996693#M155347</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;If possible, one of ways is to create sort column in power query editor.&lt;BR /&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;let
    Source = source,
    #"Sorted Rows" = Table.Sort(Source,{{"CATEGORY Nr.", Order.Ascending}, {"NAME", Order.Ascending}}),
    #"Grouped Rows" = Table.Group(#"Sorted Rows", {"CATEGORY Nr."}, {{"Count", each Table.AddIndexColumn( _, "index",1,1)}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"NAME", "index"}, {"NAME", "index"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Count", "sort_order", each [#"CATEGORY Nr."]*1000 + [index]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"index"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Removed Columns",{{"NAME", type text}, {"sort_order", Int64.Type}})
in
    #"Changed Type"&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jun 2024 17:37:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-sorting-for-calculated-table-circular-error/m-p/3996693#M155347</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-06-17T17:37:08Z</dc:date>
    </item>
    <item>
      <title>Re: Custom sorting for calculated table (circular error)</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-sorting-for-calculated-table-circular-error/m-p/3997631#M155460</link>
      <description>&lt;P&gt;Wow thank you, that must help a lot of people. Unfortunately I'm working with a calculated table. But I'll try to add the column to the original source table and get back to you.&lt;/P&gt;</description>
      <pubDate>Tue, 18 Jun 2024 06:59:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Custom-sorting-for-calculated-table-circular-error/m-p/3997631#M155460</guid>
      <dc:creator>Joris_NL</dc:creator>
      <dc:date>2024-06-18T06:59:44Z</dc:date>
    </item>
  </channel>
</rss>

