<?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: Parent-child hierarchy with changing number of levels and possibility to filter by any level in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4118244#M163496</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was exactly what i needed. Thanks! I've slightly modified it for my needs and removed&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Person] &amp;lt;&amp;gt; [Manager] &lt;/PRE&gt;&lt;P&gt;from the expression becuase i would like to use the same field for both task owner (Person) and manager. And in case if Person does not have manager, then this person will be excluded from the field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile i've found other solution. I've used this function&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=vjfeZojshxQ" target="_blank" rel="noopener"&gt;Dynamically solve parent child hierarchies in Power BI and Power Query (youtube.com)&lt;/A&gt;&amp;nbsp;to dynamically calculate the person-manager table in PQ. But i like your solution better as it minimize number of frictions in PQ.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 26 Aug 2024 08:51:46 GMT</pubDate>
    <dc:creator>bigk</dc:creator>
    <dc:date>2024-08-26T08:51:46Z</dc:date>
    <item>
      <title>Parent-child hierarchy with changing number of levels and possibility to filter by any level</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4114217#M163300</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to report data on task owner and multiple levels of task owner's managers. The end result would be a slicer where i can select any level of manager and get all tasks for the manager and his/her subordinates. This should be possible to use in both hierarhial structure, e.g. with drilldown and flat filtering, e.g. when filter contains list of all people in org and when selecting a specific person, all his/her tasks and subordinate tasks are filtered.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is pretty much typical question and a lot of solutions can be found online. But the problem is that most of them are calculating fixed number of levels using PATHITEM expression. I don't want to limit my data to specific number of path items because the number of levels may grow over time and i don't want to monitor and change query all the time. I've found a video (&lt;A href="https://www.youtube.com/watch?v=V7XWLqdvzYM" target="_blank" rel="noopener"&gt;Managing hierarchical organizations in Power BI security roles (youtube.com)&lt;/A&gt;) that almost solves my issue but the difference there is that the Permissions table in the video contains all managers for specific user in individual rows. While i have only one child-parent combination per row&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Contacts table&lt;/STRONG&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Person&lt;/TD&gt;&lt;TD&gt;Manager&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Org Hierarchy (&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&amp;nbsp;P&lt;SPAN&gt;ATH&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Contacts&lt;/SPAN&gt;&lt;SPAN&gt;[Person]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;Contacts&lt;/SPAN&gt;&lt;SPAN&gt;[Manager]&lt;/SPAN&gt;&lt;SPAN&gt;))&lt;/SPAN&gt;&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;John&lt;/TD&gt;&lt;TD&gt;Mike&lt;/TD&gt;&lt;TD&gt;Mike|John&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Mike&lt;/TD&gt;&lt;TD&gt;Anna&lt;/TD&gt;&lt;TD&gt;Anna|Mike|John&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Anna&lt;/TD&gt;&lt;TD&gt;Michael&lt;/TD&gt;&lt;TD&gt;Michael|Anna|Mike|John&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Joseph&lt;/TD&gt;&lt;TD&gt;Anna&lt;/TD&gt;&lt;TD&gt;Michael|Anna|Joseph&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Michele&lt;/TD&gt;&lt;TD&gt;Michael&lt;/TD&gt;&lt;TD&gt;Michael|Michele&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Claudia&lt;/TD&gt;&lt;TD&gt;&lt;EM&gt;null&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;Claudia&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Michael&lt;/TD&gt;&lt;TD&gt;&lt;EM&gt;null&lt;/EM&gt;&lt;/TD&gt;&lt;TD&gt;Michael&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;End result should be:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Filter by Michael would return tasks for Michael, Anna, Mike, John&lt;/LI&gt;&lt;LI&gt;Filter by Anna would return tasks for Anna, Joseph, Mike, John&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;When following video, i've made following table:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;ManagerReport=&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;GENERATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;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V&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Results are:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;As you can see, i'm getting only closest level parent name instead of all managers in the hierarchy. For example, all owners should have rows where Michael is manager, but only Anna and Michele have that as Michael is closest manager.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for looking into this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 22 Aug 2024 21:00:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4114217#M163300</guid>
      <dc:creator>bigk</dc:creator>
      <dc:date>2024-08-22T21:00:02Z</dc:date>
    </item>
    <item>
      <title>Re: Parent-child hierarchy with changing number of levels and possibility to filter by any level</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4114531#M163315</link>
      <description>&lt;P&gt;instead of PATHITEM use PATHCONTAINS.&amp;nbsp; Of course that will fail if two people have the same name.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 01:56:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4114531#M163315</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-08-23T01:56:26Z</dc:date>
    </item>
    <item>
      <title>Re: Parent-child hierarchy with changing number of levels and possibility to filter by any level</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4115014#M163332</link>
      <description>&lt;P&gt;Hi. Thanks for reply. However i did not get your suggestion. Currently i don't have any query except the one that is listed above. PATHITEM was referred as a solution that does not fit me because it is used to split hierarchy to multiple columns which is not the solution i'm looking for. And the query above actually already contains PATHCONTAINS.&lt;/P&gt;</description>
      <pubDate>Fri, 23 Aug 2024 06:42:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4115014#M163332</guid>
      <dc:creator>bigk</dc:creator>
      <dc:date>2024-08-23T06:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Parent-child hierarchy with changing number of levels and possibility to filter by any level</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4118017#M163484</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="769889" data-lia-user-login="bigk" class="lia-mention lia-mention-user"&gt;bigk&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks&amp;nbsp;lbendlin&amp;nbsp; for the quick reply. I have some other thoughts to add:&lt;/P&gt;
&lt;P&gt;(1)&amp;nbsp;My test data is the same as yours.&lt;/P&gt;
&lt;P&gt;(2) Create two columns.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Org Hierarchy = PATH(Contacts[Person],Contacts[Manager])&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;Column = PATHLENGTH([Org Hierarchy])&lt;/LI-CODE&gt;
&lt;P&gt;(3) Create a table.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Table =
VAR table1 =
    GENERATESERIES ( 1, MAX ( Contacts[Column] ), 1 )
VAR table2 =
    ADDCOLUMNS (
        GENERATEALL ( VALUES ( Contacts[Person] ), table1 ),
        "Manager",
            VAR a =
                MAXX (
                    FILTER ( Contacts, [Person] = EARLIER ( Contacts[Person] ) ),
                    [Org Hierarchy]
                )
            RETURN
                PATHITEM ( a, [Value] )
    )
RETURN
    FILTER ( table2, [Manager] &amp;lt;&amp;gt; BLANK () &amp;amp;&amp;amp; [Person] &amp;lt;&amp;gt; [Manager] )
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Neeko Tang&lt;/P&gt;
&lt;P&gt;If this post  &lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider &lt;STRONG&gt;&lt;EM&gt;Accept it as the solution &lt;/EM&gt;&lt;/STRONG&gt; to help the other members find it more quickly.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2024 07:10:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4118017#M163484</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-26T07:10:49Z</dc:date>
    </item>
    <item>
      <title>Re: Parent-child hierarchy with changing number of levels and possibility to filter by any level</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4118244#M163496</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This was exactly what i needed. Thanks! I've slightly modified it for my needs and removed&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Person] &amp;lt;&amp;gt; [Manager] &lt;/PRE&gt;&lt;P&gt;from the expression becuase i would like to use the same field for both task owner (Person) and manager. And in case if Person does not have manager, then this person will be excluded from the field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Meanwhile i've found other solution. I've used this function&amp;nbsp;&lt;A href="https://www.youtube.com/watch?v=vjfeZojshxQ" target="_blank" rel="noopener"&gt;Dynamically solve parent child hierarchies in Power BI and Power Query (youtube.com)&lt;/A&gt;&amp;nbsp;to dynamically calculate the person-manager table in PQ. But i like your solution better as it minimize number of frictions in PQ.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 26 Aug 2024 08:51:46 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Parent-child-hierarchy-with-changing-number-of-levels-and/m-p/4118244#M163496</guid>
      <dc:creator>bigk</dc:creator>
      <dc:date>2024-08-26T08:51:46Z</dc:date>
    </item>
  </channel>
</rss>

