<?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: DAX statement that groups and creates index dynamically in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4601110#M176141</link>
    <description>&lt;P&gt;you provide a&amp;nbsp;&lt;SPAN&gt;&amp;lt;orderBy_expression&amp;gt; so only can't&amp;nbsp;guarantee sort order if there are ties&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Mar 2025 20:44:17 GMT</pubDate>
    <dc:creator>Deku</dc:creator>
    <dc:date>2025-03-07T20:44:17Z</dc:date>
    <item>
      <title>DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4595414#M175978</link>
      <description>&lt;P&gt;Greetings:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a report where I utilized the Microsoft Gannt visual.&amp;nbsp; In typical Gannt fashion it will put the Gannt element with the oldest date on top and then sort accordingly on date; top to bottom, left to right with the calendar hash on top.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It also has a feature where you can assign a "Parent" category to the individual Gantt items.&amp;nbsp; When applying the Parent category the visual will find the Gantt element ("Child") with the oldest date and then group all of the other elements that correspond to the Parent and sort them.&amp;nbsp; Effectively, it groups on the parent, find the parent with the oldest date, then sorts the elements within. Rinse and repeat.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I combined the Gannt visual on top with a table visual on the bottom of the page; that table visual providing a more structured grid of details.&amp;nbsp;I created an index in Power Query that replicates the logic and apply the index to Sort By Column in the model. At initial load all is good.&amp;nbsp; The sorting of the table matches the sorting of the Gantt.&amp;nbsp; What I didn't consider is that when one changes the domain of start dates (i.e. show me all the elements whose start date is in month X) that Gannt visual does it group and sort again just fine, the table is still utilizing the unsliced, undynamic index built in Power Query.&amp;nbsp; They are out of sorts.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I'm trying to create and failing is a DAX statement where it would dynamically generate a index that matches the Gannt sort logic.&amp;nbsp; It's a bit of hack, but the thinking is that when a user sliced the report and changed the domain of start dates, they could use the measurement persisted as a column on the table to make the table sort match the Gantt.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried employing&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="313" data-lia-user-login="Greg_Deckler" class="lia-mention lia-mention-user"&gt;Greg_Deckler&lt;/a&gt;&amp;nbsp;suggestion found &lt;A href="https://community.fabric.microsoft.com/t5/Quick-Measures-Gallery/The-Mythical-DAX-Index/m-p/1093214#M528" target="_self"&gt;here&lt;/A&gt;&amp;nbsp;&amp;nbsp;without sucess.&amp;nbsp; Below are some redacted screen shots to provide some visual clues.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 18:06:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4595414#M175978</guid>
      <dc:creator>jmg80525</dc:creator>
      <dc:date>2025-03-04T18:06:34Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4595417#M175979</link>
      <description>&lt;P&gt;You can use &lt;A href="https://learn.microsoft.com/en-us/dax/substitutewithindex-function-dax" target="_self"&gt;SUBSTITUTEWITHINDEX &lt;/A&gt;to perform a multi column ranking. Add the measure to the table and sort the table by it. Then reduce the columns width until it is not visible&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See this &lt;A href="https://youtu.be/aMbtfBzTtBc?si=qwshp3MzIhNnEr81" target="_self"&gt;video&lt;/A&gt; by SQLBI&lt;/P&gt;</description>
      <pubDate>Tue, 04 Mar 2025 18:15:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4595417#M175979</guid>
      <dc:creator>Deku</dc:creator>
      <dc:date>2025-03-04T18:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4597266#M176017</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="11604" data-lia-user-login="jmg80525" class="lia-mention lia-mention-user"&gt;jmg80525&lt;/a&gt;&amp;nbsp;Any chance you can provide a sample PBIX file or sample data?&amp;nbsp;Sorry, having trouble following, can you post sample data as text and expected output?&lt;BR /&gt;Not really enough information to go on, please first check if your issue is a common issue listed here: &lt;A href="https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Also, please see this post regarding How to Get Your Question Answered Quickly: &lt;A href="https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490" target="_blank"&gt;https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;The most important parts are:&lt;BR /&gt;1. Sample data as text, use the table tool in the editing bar&lt;BR /&gt;2. Expected output from sample data&lt;BR /&gt;3. Explanation in words of how to get from 1. to 2.&lt;/P&gt;</description>
      <pubDate>Wed, 05 Mar 2025 21:01:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4597266#M176017</guid>
      <dc:creator>Greg_Deckler</dc:creator>
      <dc:date>2025-03-05T21:01:53Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4601098#M176139</link>
      <description>&lt;P&gt;Here's a &lt;A href="https://interfacegisinc-my.sharepoint.com/:u:/g/personal/jeff_garland_interfacegis_com/EYidGFwjTsJBhTsNmKmyYgABMoxQYYZFgzTlAUYrli742A?e=cnFwyy" target="_self"&gt;link&lt;/A&gt; to a sample PBIX.&amp;nbsp; A precursory glance at SubstitueWithIndex documentation suggests that&amp;nbsp;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;&lt;P&gt;This function does not guarantee any result sort order.&lt;/P&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;.&amp;nbsp; To replicate the issue choose June on the calendar slicer. Note the reordering of the regions in the Gannt chart.&amp;nbsp; You will see that I have ordered sorting on the RegionSort column and ProjectName uses StartDate&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 20:34:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4601098#M176139</guid>
      <dc:creator>jmg80525</dc:creator>
      <dc:date>2025-03-07T20:34:21Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4601110#M176141</link>
      <description>&lt;P&gt;you provide a&amp;nbsp;&lt;SPAN&gt;&amp;lt;orderBy_expression&amp;gt; so only can't&amp;nbsp;guarantee sort order if there are ties&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Mar 2025 20:44:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4601110#M176141</guid>
      <dc:creator>Deku</dc:creator>
      <dc:date>2025-03-07T20:44:17Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4601897#M176171</link>
      <description>&lt;P&gt;As already mentioned, we would need a more specific sample to work with to troubleshoot the issue.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Speaking at a very high level, though, if you have a date slicer that filters the Gantt data, and you want it to similarly filter the table data, then you need to set up a relationship between Date -1--M-&amp;gt; Table the same as you should have a relationship between Date -1--M-&amp;gt; Gantt.&lt;/P&gt;</description>
      <pubDate>Sun, 09 Mar 2025 05:36:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4601897#M176171</guid>
      <dc:creator>MarkLaf</dc:creator>
      <dc:date>2025-03-09T05:36:51Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4602597#M176194</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="11604" data-lia-user-login="jmg80525" class="lia-mention lia-mention-user"&gt;jmg80525&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;Did the replies offered help you solve the problem, if it helps, you can consider to accept it as a solution so that more user can refer to, or if you have other problems, you can offer some information so that can provide more suggestion for you.&lt;/P&gt;
&lt;P&gt;Best regards,&lt;/P&gt;
&lt;P&gt;Lucy Chen&lt;/P&gt;</description>
      <pubDate>Mon, 10 Mar 2025 06:06:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4602597#M176194</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-03-10T06:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4607532#M176379</link>
      <description>&lt;P&gt;K. I tried running w/SubstituteWithIndex.&amp;nbsp; I'm a bit over my DAX paygrade. I could get the code below to return a table in the DAX editor. But I can't figure out how to implement that as a measure that I drop into a visual.&amp;nbsp; I reworked and simplified the PBIX.&amp;nbsp; Here's a &lt;A href="https://interfacegisinc-my.sharepoint.com/:u:/g/personal/jeff_garland_interfacegis_com/EYidGFwjTsJBhTsNmKmyYgABMoxQYYZFgzTlAUYrli742A?e=0hzKbO" target="_self"&gt;link.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;DEFINE

VAR A =
    SUMMARIZECOLUMNS(
        Sample[Region],      -- Group by the Region column
        Sample[StartDate],   -- Group by the StartDate column
        Sample[UniqueID]        -- Include UniqueID to ensure uniqueness
    )

VAR B =
    SUMMARIZECOLUMNS(
        Sample[StartDate],    -- Group by the StartDate column
        Sample[Region],       -- Group by the Region column
        Sample[UniqueID]         -- Include UniqueID to ensure uniqueness
    )

VAR Result =
    SUBSTITUTEWITHINDEX(A, "Magic", B, 'Sample'[UniqueID], ASC)

EVALUATE
    A
EVALUATE
    B
EVALUATE
    Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp; Could use a little additional help to get my over the hump.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 20:36:57 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4607532#M176379</guid>
      <dc:creator>jmg80525</dc:creator>
      <dc:date>2025-03-12T20:36:57Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4607620#M176381</link>
      <description>&lt;LI-CODE lang="markup"&gt;measure =
rnk = 
VAR A =
    ADDCOLUMNS(
        ALLSELECTED( 
        Sample[Region],      -- Group by the Region column
        Sample[StartDate],   -- Group by the StartDate column
        Sample[UniqueID]     -- Include UniqueID to ensure uniqueness
        ),
		"@start", CALCULATE(MAX(Sample[StartDate])), 
        "@region", CALCULATE(MAX(Sample[Region])),   
        "@id", CALCULATE(MAX(Sample[UniqueID]))    
    )

VAR B =
    ALLSELECTED( 
        Sample[Region],      -- Group by the Region column
        Sample[StartDate],   -- Group by the StartDate column
        Sample[UniqueID]     -- Include UniqueID to ensure uniqueness
    )
VAR rnk = SUBSTITUTEWITHINDEX(A, "@rank", B, 'Sample'[UniqueID], ASC)
RETURN
MAXX(
    FILTER(
        rnk,
        SELECTEDVALUE( 'Sample'[Region] ) = [@region] &amp;amp;&amp;amp;
        SELECTEDVALUE( 'Sample'[StartDate] ) = [@start] &amp;amp;&amp;amp;
        SELECTEDVALUE('Sample'[UniqueID]) = [@id]
    ),
    [@rank]
)&lt;/LI-CODE&gt;&lt;P&gt;you still need to play with the sorting expression&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 12 Mar 2025 22:02:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4607620#M176381</guid>
      <dc:creator>Deku</dc:creator>
      <dc:date>2025-03-12T22:02:33Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4717410#M180683</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="11604" data-lia-user-login="jmg80525" class="lia-mention lia-mention-user"&gt;jmg80525&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.&lt;/P&gt;
&lt;P&gt;Thank you.&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 02 Jun 2025 19:43:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4717410#M180683</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-06-02T19:43:13Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4724123#M180952</link>
      <description>&lt;P&gt;&lt;SPAN data-teams="true"&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="11604" data-lia-user-login="jmg80525" class="lia-mention lia-mention-user"&gt;jmg80525&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If response has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.&lt;BR /&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sat, 07 Jun 2025 17:07:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4724123#M180952</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-06-07T17:07:10Z</dc:date>
    </item>
    <item>
      <title>Re: DAX statement that groups and creates index dynamically</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4726913#M181070</link>
      <description>&lt;P&gt;&lt;SPAN data-teams="true"&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="11604" data-lia-user-login="jmg80525" class="lia-mention lia-mention-user"&gt;jmg80525&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;I hope this information is helpful. Please let me know if you have any further questions or if you'd like to discuss this further. If this answers your question, please &lt;STRONG&gt;Accept it as a solution&lt;/STRONG&gt; and give it a '&lt;STRONG&gt;Kudos&lt;/STRONG&gt;' so others can find it easily.&lt;BR /&gt;Thank you.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Jun 2025 10:08:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-statement-that-groups-and-creates-index-dynamically/m-p/4726913#M181070</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-06-10T10:08:13Z</dc:date>
    </item>
  </channel>
</rss>

