<?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 make hierarchical path use visual filters in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1917490#M41533</link>
    <description>&lt;P&gt;Hey Owen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much, that solved the problem. I lost two days jumping around it. You rock! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;D. Senkovic&lt;/P&gt;</description>
    <pubDate>Wed, 23 Jun 2021 12:52:31 GMT</pubDate>
    <dc:creator>DSenkovic</dc:creator>
    <dc:date>2021-06-23T12:52:31Z</dc:date>
    <item>
      <title>How to make hierarchical path use visual filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1915203#M41446</link>
      <description>&lt;P&gt;Hi everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a table which contains some hierarchical data with id and parentid fields among others fields.&lt;/P&gt;&lt;P&gt;I can create appropriate structure with PATH (and other path related DAX functions). I can also display it visually with level hierarchy in Hierarchy Slicer.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Each row in this table additionally has certain numeric field. What I need to determine is the value of this field for the top-most selected (not filtered-out) parent leaf for each row.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So, for example, for tree like this with this significant numeric value written in parentheses next to node names:&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;N(5)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/&amp;nbsp; \&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N1(7)&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; N2(8)&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;/&amp;nbsp; \&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; /&amp;nbsp; &amp;nbsp;\&lt;/P&gt;&lt;P&gt;&amp;nbsp;N11(4)&amp;nbsp; N12(6)&amp;nbsp; &amp;nbsp; &amp;nbsp;N13(2)&amp;nbsp; &amp;nbsp;N14(9)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If all nodes are selected in a slicer, I need to get value (5) for all rows (in some new measure or column) as the value, since 5 is the field value of top-most parent.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If N1, N11 and N12 are the only ones selected then all three of them should have (7) as a value for this new field.&lt;/P&gt;&lt;P&gt;If on the other hand N13 is the only one selected then it should have (2) as a value for this field.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am able to acchieve this with PATH related functions but I cannot make it work with filters applied. It always works on an entire dataset and always returns topmost value (5) for all rows.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. This should also work with URL filtering when table rows are filtered by external URL parameters when embedding powerBI report in a web page.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help is appreciated. Thank you very much.&lt;/P&gt;</description>
      <pubDate>Tue, 22 Jun 2021 15:34:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1915203#M41446</guid>
      <dc:creator>DSenkovic</dc:creator>
      <dc:date>2021-06-22T15:34:50Z</dc:date>
    </item>
    <item>
      <title>Re: How to make hierarchical path use visual filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1916324#M41492</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="308667" data-lia-user-login="DSenkovic" class="lia-mention lia-mention-user"&gt;DSenkovic&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here's an initial idea - PBIX attached.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm working on the assumption that you have a data model with:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;STRONG&gt;Nodes&lt;/STRONG&gt; table, with columns Node, Parent and Path (created using PATHITEM)&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;NodeValue&lt;/STRONG&gt; table containing Node and Value columns.&lt;/LI&gt;
&lt;LI&gt;Relationship between NodeValue[Node] and Nodes[Node]&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Path = 
PATH ( Nodes[Node], Nodes[Parent] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then you can create a measure like the one below (note that this can most likely be optimized).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Assumptions I made in writing the measure:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;You only want the measure evaluated for a single node at a time.&lt;/LI&gt;
&lt;LI&gt;The measure calculates the value sum for the topmost node in the path for the currently filtered node, within the overall selection of nodes (using ALLSELECTED).&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Topmost node value = 
VAR CurrentNode =
    SELECTEDVALUE ( Nodes[Node] )
RETURN
    IF (
        NOT ISBLANK ( CurrentNode ),
        -- Only return result if single node selected
        VAR CurrentNodePath =
            -- Get path of current node
            SELECTEDVALUE ( Nodes[Path] )
        VAR CurrentNodePathLength =
            PATHLENGTH ( CurrentNodePath )
        VAR CurrentNodePathTable =
            -- Table containing Node/Position pairs for CurrentNodePath
            SELECTCOLUMNS (
                GENERATESERIES ( 1, CurrentNodePathLength ),
                -- Table of values {1,2,...,CurrentNodePathLength}
                "@Node", PATHITEM ( CurrentNodePath, [Value] ),
                "@Position", [Value]
            )
        VAR VisibleNodesAllSelected =
            -- List of all nodes selected overall
            CALCULATETABLE (
                VALUES ( Nodes[Node] ),
                ALLSELECTED ()
            )
        VAR CurrentNodePathTableFiltered =
            -- Filter path to just those nodes selected overall
            FILTER (
                CurrentNodePathTable,
                [@Node] IN VisibleNodesAllSelected
            )
        VAR TopNode =
            -- Get the top Node (i.e. with minimum position in the path)
            -- and treat as Nodes[Node] value
            TREATAS (
                SELECTCOLUMNS (
                    TOPN ( 1, CurrentNodePathTableFiltered, [@Position], ASC ),
                    "@TopNode", [@Node]
                ),
                Nodes[Node]
            )
        RETURN
            CALCULATE ( [Value Sum], TopNode, ALL ( Nodes ) )
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;For example, if you select N1, N11, N12, N2, N14, then:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;N1, N11 and N12 have Topmost node value = 7&lt;/LI&gt;
&lt;LI&gt;N2 and N14 have Topmost node value = 8&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hopefully this is of some use and can be adapted to your model.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 04:53:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1916324#M41492</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-06-23T04:53:34Z</dc:date>
    </item>
    <item>
      <title>Re: How to make hierarchical path use visual filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1917490#M41533</link>
      <description>&lt;P&gt;Hey Owen,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you so much, that solved the problem. I lost two days jumping around it. You rock! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;D. Senkovic&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 12:52:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1917490#M41533</guid>
      <dc:creator>DSenkovic</dc:creator>
      <dc:date>2021-06-23T12:52:31Z</dc:date>
    </item>
    <item>
      <title>Re: How to make hierarchical path use visual filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1918550#M41583</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp; Thank you for your help so far. Just a quick question.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I had a new (child) table to the Node table - let's call it a Leaf table. It has foreign key to node_id of course among other fields. Any Node can have any number of Leaves.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I needed to display the Topmost node measure value in the visual that displays the Leaves data of selected Nodes, I suppose that the measure would need to be changed in a way that SELECTEDVALUE is no longer the way to get the current node for the Leaf. I should somehow use the Node from the filter context of the Leaf.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is that correct way of thinking? Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 23 Jun 2021 23:00:53 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1918550#M41583</guid>
      <dc:creator>DSenkovic</dc:creator>
      <dc:date>2021-06-23T23:00:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to make hierarchical path use visual filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1925584#M41759</link>
      <description>&lt;P&gt;You're welcome! &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;I just managed to get back to looking at this.&lt;/P&gt;
&lt;P&gt;The exact way of handling this depends on your data model setup.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have attached an updated PBIX using option 1 below, with a &lt;STRONG&gt;NodeChild&lt;/STRONG&gt; table added.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;You could set up the model with the NodeChild table having a bidirectional relationship with the Node table. This would mean the filter on a Child would propogate to the corresponding node.&lt;BR /&gt;&lt;BR /&gt;There would just be a small tweak required to the measure near the end, changing &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ALL ( Nodes )&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN style="font-family: inherit;"&gt; to &lt;/SPAN&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;ALLCROSSFILTERED ( Nodes )&lt;/STRONG&gt;&lt;/FONT&gt;&lt;SPAN style="font-family: inherit;"&gt;. This is because we need to remove all filters affecting the Nodes table, including those on the many-side of a relationship with &lt;/SPAN&gt;&lt;STRONG style="font-family: inherit;"&gt;Nodes&lt;/STRONG&gt;&lt;SPAN style="font-family: inherit;"&gt;.&lt;BR /&gt;&lt;BR /&gt;&lt;EM&gt;&lt;STRONG&gt;I have used this method in the attached PBIX.&lt;/STRONG&gt;&lt;/EM&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/LI&gt;
&lt;LI&gt;If you don't&amp;nbsp;have a bidirectional relationship between &lt;STRONG style="font-family: inherit;"&gt;Nodes&lt;/STRONG&gt;&lt;SPAN style="font-family: inherit;"&gt; and &lt;/SPAN&gt;&lt;STRONG style="font-family: inherit;"&gt;NodeChild,&amp;nbsp;&lt;/STRONG&gt;then you need to use DAX to filter &lt;STRONG&gt;Nodes&lt;/STRONG&gt; based on &lt;STRONG&gt;NodeChild. &lt;/STRONG&gt;There are different ways to do this, but one is to wrap the SELECTEDVALUE calls in CALCULATE with NodeChild as a filter argument, so you end up with code like below:&lt;/LI&gt;
&lt;/OL&gt;
&lt;LI-CODE lang="markup"&gt;VAR CurrentNode =
    CALCULATE ( 
        SELECTEDVALUE ( Nodes[Node] ),
        NodeChild
    )

VAR CurrentNodePath =
    CALCULATE (
        SELECTEDVALUE ( Nodes[Path] ),
        NodeChild
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Hope this helps!&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 10:46:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1925584#M41759</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2021-06-28T10:46:04Z</dc:date>
    </item>
    <item>
      <title>Re: How to make hierarchical path use visual filters</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1926614#M41786</link>
      <description>&lt;P&gt;Thank you!&lt;/P&gt;</description>
      <pubDate>Mon, 28 Jun 2021 20:15:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/How-to-make-hierarchical-path-use-visual-filters/m-p/1926614#M41786</guid>
      <dc:creator>DSenkovic</dc:creator>
      <dc:date>2021-06-28T20:15:12Z</dc:date>
    </item>
  </channel>
</rss>

