<?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 to display 2 levels of Hierarchy based on filter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958586#M11097</link>
    <description>Also, for this to work, the level in AllLevels must be the level of the child, not of the parent.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
    <pubDate>Wed, 04 Mar 2020 11:40:15 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-04T11:40:15Z</dc:date>
    <item>
      <title>DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/956223#M10969</link>
      <description>&lt;P&gt;I have a hierarchy table that looks like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&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;&amp;nbsp;&lt;/P&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;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And a fact table like this:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;And a simple model:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;I have created a report with a Hierarchy Slicer and a Matrix as shown below.&amp;nbsp; But I also need to be able to display the table that is shown on the right.&amp;nbsp; In the sample shown, the user has selected "Node A.A" in the slicer, and the table needs to display the selected node ("Node A.A"), plus the 2 children ("Node A.A.A" and "Node A.A.B"), aggregating the data for them.&amp;nbsp; Is there a dax formula I can write that I can then use to filter this table?&amp;nbsp; Just to clarify, the requiement is to display the selected/filtered node and all children that are one level below.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Note, real model is build using SSAS Tabular 2017, so some functions are not available (such as IsInScope).&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 03:21:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/956223#M10969</guid>
      <dc:creator>cmncp</dc:creator>
      <dc:date>2020-03-03T03:21:19Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/956432#M10979</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="19688" data-lia-user-login="cmncp" class="lia-mention lia-mention-user"&gt;cmncp&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;cannot you just remove Level3 and Level4 from hierarchy in visual fields pane&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 07:06:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/956432#M10979</guid>
      <dc:creator>az38</dc:creator>
      <dc:date>2020-03-03T07:06:39Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/957546#M11060</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="82403" data-lia-user-login="az38" class="lia-mention lia-mention-user"&gt;az38&lt;/a&gt; No, because I need to display the selected node and all children.&amp;nbsp; So in the example, the user selected Node A.A and therefore we display that node plus its immediate children (Node A.A.A and Node A.A.B).&amp;nbsp; If the choses Node A.A.B, then we need to display Node A.A.B and its immediate children (Node A.A.B.A and node A.A.B.B).&amp;nbsp; It is all relative to the selection the user makes in the slicer.&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 21:01:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/957546#M11060</guid>
      <dc:creator>cmncp</dc:creator>
      <dc:date>2020-03-03T21:01:06Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/957649#M11070</link>
      <description>&lt;P&gt;The best way to achieve this is by creating another table that will store 2 columns:&lt;BR /&gt;- a column with each node&lt;BR /&gt;- a column with each subnode that corresponds to the node in the first column plus the node from the first column. The table should be connected to Node Name in the first table (dimension with all the levels). The filtering would be 1:* from the hierarchy dimension to the said table. You would display the figures only when one node would be selected from the hierarchy dimension. A visual displays nothing if the column with a measure has blanks - use this feature to your advantage.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;BR /&gt;D&lt;/P&gt;</description>
      <pubDate>Tue, 03 Mar 2020 23:01:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/957649#M11070</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-03T23:01:13Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/957717#M11074</link>
      <description>&lt;P&gt;Hi Anonymous&lt;/a&gt; Thanks for the suggestion, but I can't quite get it to work.&amp;nbsp; I have added the table like this:&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And created relationship back to hierarchy table based on Children to NodeName:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when I build my report and select the top "Node A" in my slicer, I still get all levels showing.&amp;nbsp; How do I restrict the table to just 2 levels?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;I have uploaded my PBIX file here: &lt;A href="https://drive.google.com/open?id=13oxTuna3j9EYzvH7lkJb1dExq3k3U6oH" target="_blank" rel="noopener"&gt;https://drive.google.com/open?id=13oxTuna3j9EYzvH7lkJb1dExq3k3U6oH&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 00:27:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/957717#M11074</guid>
      <dc:creator>cmncp</dc:creator>
      <dc:date>2020-03-04T00:27:32Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958471#M11093</link>
      <description>&lt;P&gt;Hi there. It's the Parent that has to be connected to Node Name, not the children. Once this is done, then selecting a single node in Hierarchy will give you in AllLevels the children of the node and the node itself (in the Children column). You also have to have a measure that will work with AllLevels in such a way that it'll return the values for the visible Children when only one node is selected in Hierarchy. All the other rows will receive BLANK. This way your table created from Children and the measure will show what you want.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Bear in mind, though, that the measure you'll be creating to achieve this will have to rely on virtual relationships and TREATAS is your friend. If you can't use TREATAS, you'll&amp;nbsp; be relying on INTERSECT. The filtering should be from Hierarchy to AllLevels in a 1:* fashion (no cross-filtering as you don't need this at all and it would be confusing to say the least).&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm at work and can't therefore open or even download files from a Google Drive. Could you please place the file somewhere else? Maybe OneDrive?&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 10:18:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958471#M11093</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-04T10:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958536#M11094</link>
      <description>&lt;P&gt;Once you've got the correct setup, you'll write something like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Say [Total Sales] works OK for any node.
//
// Relationships:
// Hierarchy[Node Name] 1 -&amp;gt; * Sales[Node Name]
// Hierarchy[Node Name] 1 -&amp;gt; * AllLevels[Parent]
//
// The measure that'll work with AllLevels:

[Node Sales] =
var __oneNodeVisible = HASONEVALUE( AllLevels[Parent] )
var __oneSubnodeVisible = HASONEVALUE( AllLevels[Children] )
var __shouldCalc =
	__oneNodeVisible &amp;amp;&amp;amp; __oneSubnodeVisible
var __subnode = SELECTEDVALUE( AllLevels[Children] )
var __result = 
	CALCULATE(
		[Total Sales],
		Hierarchy[Node Name] = __subnode,
		ALL( Hierarchy )
	)
return
	if( __shouldCalc, __result )&lt;/LI-CODE&gt;
&lt;P&gt;Or something similar... You might need to discover which level the node belongs to and then make changes to __result accordingly.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 10:56:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958536#M11094</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-04T10:56:48Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958554#M11095</link>
      <description>&lt;P&gt;Or something like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Say [Total Sales] works OK for any node.
//
// Relationships:
// Hierarchy[Node Name] 1 -&amp;gt; * Sales[Node Name]
// Hierarchy[Node Name] 1 -&amp;gt; * AllLevels[Parent]
//
// The measure that'll work with AllLevels:

[Node Sales] =
var __oneNodeVisible = HASONEVALUE( AllLevels[Parent] )
var __oneSubnodeVisible = HASONEVALUE( AllLevels[Children] )
var __shouldCalc =
	__oneNodeVisible &amp;amp;&amp;amp; __oneSubnodeVisible
var __subnode = SELECTEDVALUE( AllLevels[Children] )
var __level = SELECTEDVALUE( AllLevels[Level] )
var __level1Result =
	CALCULATE(
		[Total Sales],
		Hierarchy[Level1] = __subnode,
		ALL( Hierarchy )
	)
var __level2Result =
	CALCULATE(
		[Total Sales],
		Hierarchy[Level2] = __subnode,
		ALL( Hierarchy )
	)
var __level3Result =
	CALCULATE(
		[Total Sales],
		Hierarchy[Level3] = __subnode,
		ALL( Hierarchy )
	)
var __level4Result =
	CALCULATE(
		[Total Sales],
		Hierarchy[Level4] = __subnode,
		ALL( Hierarchy )
	)
var __result = 
	switch( __level,
		1, __level1Result,
		2, __level2Result,
		3, __level3Result
		4, __level4Result,
		"This should not happen"
	)
return
	if( __shouldCalc, __result )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best&lt;/P&gt;
&lt;P&gt;D&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 11:09:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958554#M11095</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-04T11:09:02Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958586#M11097</link>
      <description>Also, for this to work, the level in AllLevels must be the level of the child, not of the parent.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Wed, 04 Mar 2020 11:40:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958586#M11097</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-04T11:40:15Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958660#M11100</link>
      <description>I got it to work but I had to change the model. I've got the file on my OneDrive and I'll share as soon as possible.&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Wed, 04 Mar 2020 12:41:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958660#M11100</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-04T12:41:30Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958661#M11101</link>
      <description>Here's the link. Take a look at how I create the LxToLx tables and how the Parent Level and Child Level are used in the measure.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://1drv.ms/u/s!ApyQEauTSLtOgYJQZeQffdQS0PwRTg?e=XABEbl" target="_blank"&gt;https://1drv.ms/u/s!ApyQEauTSLtOgYJQZeQffdQS0PwRTg?e=XABEbl&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Wed, 04 Mar 2020 12:43:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/958661#M11101</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-04T12:43:36Z</dc:date>
    </item>
    <item>
      <title>Re: DAX to display 2 levels of Hierarchy based on filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/959349#M11156</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;That's awesome work.&amp;nbsp; Let me have a play around with it today.&amp;nbsp; Thanks for going to all that effort.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Mar 2020 21:09:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-to-display-2-levels-of-Hierarchy-based-on-filter/m-p/959349#M11156</guid>
      <dc:creator>cmncp</dc:creator>
      <dc:date>2020-03-04T21:09:56Z</dc:date>
    </item>
  </channel>
</rss>

