cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
modi123p
Helper III
Helper III

Hierarchical data: Validator measure to filter data at selected node and its child nodes

Hi,

User wishes to select a node and filter all visuals for data at the selected level and its child nodes.

For example, if Location 1.1 is selected in the filter, all nodes in the hierarchy starting from 1.1 (like 1.1.2, 1.1.1.1, like 1.1.1.2 ...etc need to be selected)

* Using hierarchical slicer/ list filter with hierarchy is not an option

* There are 6 levels and master data is extremely large. Using Power query to do a self join is not feasible.

 

I created a measure that validates data with only one Location being selected.

However, I m unable to get it working for multiple locations.

Need help with the Validator measure.

 

Validator =
var _x = SELECTEDVALUE('PARAM Locations'[Level])
var _selectedPath = SELECTEDVALUE('PARAM Locations'[Path])
var _path = _selectedPath &"|"
RETURN CALCULATE(COUNT(Amounts[Location ID]), Locations[Level]>=_x && ((Locations[Path] =_selectedPath) || CONTAINSSTRING(Locations[Path], _path)))

 

Parent-ChildCapture.PNG

 

 

Capture_PCH.PNG

 

Table Amounts:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("dVxLlvamDtzLN84ABAg0vEl2kZP9b+Pakm2qbGWQ859uAhZ6lB5I/c8/Pxm/P35rjnn887/jPyl1lfb7949/frUcP0+VhkvDl5qcu5aUZ+lYLL4UB47WcdeMpfO81Suu9Fg5f6c6Gp4nQYUeP5uJ7V12UdHPT/XjFwmB5+dNOl0rDvT7HCuwZBftXXzXUiSj+tL5K61rfGlvTsVxBp4Xn/Krtj6J9th1/kpMkPRrkzO1FiICLzysrC994yS9t9q+n6rOdysloT1EXOz35fvJwbYakXFJ6/zfR8EDT5puNol1lOMlfBeFtYqfuhStnfdpKooEWnzq/F0TQzleN+7nLps90Vwn2tpE9bwOjKXR1u+jGO2k2nR0vNb1rfN3aiTjixmnSFrtpO51c3Co6u/DJlcMq86nP/lact6nzbWepYeFK4Q1cOUi3VzR3Cyf8wREvJwXfzLp7fzU7Gq4dF34PK9ItsnVc7nR3VTc5uOki9/gIXBs9RTeVUDR1nK2v3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5pmuKPa+dEBH984Ek4/+WTWzk9mrZGTILCuxSaBsNWbYbwp1vXExIzdEx3zS4qOvT3CGB6Z81Cm3SLSk0TDfTMYvXMGq+3H1IYqMhfvUpvgZwri4f2x4Z2fRlj236pVxbw2CYnc5UvFdcfI2hJKHP9mSdLDDWipkajqlh6tcH4AyYyBn+rbXOs0TTxinKisVVIm27pB7bztPzaIp5SM1d8hXzJLi9Tdk2wM0a3LNHOmLO0nmxy/Bb+uzxA3sGy99zmv/8H", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Location ID" = _t, Amount = _t, Product = _t, YearMonth = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Amount", Int64.Type}, {"Location ID", Int64.Type}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Location ID", "Product", "YearMonth"}, {{"Amount", each List.Sum([Amount]), type nullable number}})
in
#"Grouped Rows"

 

 

Table: Locations

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("VZbZkqIwFIbfxeupKRICyp0CKptEEGTp6otWBxds941mHn5GQkK40CqL/zvbnxP8+OiAzq/WxxGK11zZRgtDeXQ+f3104PvB7+rx3/f3+/cN2MEGwX5uyXElEitRJf0La1FQhuHyZWjT625diVD9ANapsqW5W0qb+HsyHFQC6f2wSgVZKhVu8NiHi3XUdSqRXImqOCzV63GwForqDMcwqERdUjQtu4r2rnEiGKYBkKVv8b4S9qiwkVbid6250PeNuR2W8dyuxEoj5uUV8K79KlsvA4va84RIQ0DgCMgRsCbsU+rmen4duAlJAQBHiBwh1sSkF48WBpjuVyXxB0BGNBlg3ULkpLfrWZgdXD8jarFRcz1A1sNYu4WlJmArh1NCII7gMrAe9ortr9f+sx8cx4SQOELkCNpDkBZfWb5d2Re5rkrmCMQRqCZuIxwW4e5P/ND6hKAO04pg7bChmsl9GeiuA8hRANTipl/ILJ6riTZ9QOzgVd2twtQsMpvmNo2f6T2f+Y6ikd0QGjUXvZnmUvFO10Ifj9aKSQjAEVwGNk3fnLqWH04muCTThJAjRI6g07TADO9lKdmsXJUQIk+06hKryt7TjrTIOWuRF5Qvj1CoRcEWBWvKdTPvIO2uI/1kEEpqUa36qgrflCaplv16BrZ5r3siftOZQbafCQxjzUOTTJeJe7BLlY2WuWegazFayUU6S8jdAHtMDZmauveFA/WSpL6eDMkZgkqj5qI37pnSMJndBwY+ByW55gSO4DIw99Ifoz/aH8rnHCWEABwhcgR1bwnHR3w0sjRWiHsi5AjEEXQXNobvWpvnPZogcgrF+vZlFdFdcBb69ftyc/LLpr6mEVWyfptdcLY4WXelb/U4IneRKDE1i8ym6cpumBby3QqBRdRyo+aiN9N09K3hgelycZn4hOhyBJeBTdOTbM84PDaeNyb+ij2OEDmCTnMANF/PD3r4c3kSQuGJVl3NLoTCZTk7b9dm3COnDgktCrYougs/mRlqsn5ejqUToUCLatXHduFPiOOV8mVO/RXxBFUvsd/0vdfsws41/OmtULP0+CJKsVbWLz/m8+jnPPAQSKIonxElokoWtfE5LpzwlC2wp2XkzkMSU7PIzOdMKnVsSduVOiPvNCQ3ai5647PWKweOlKZBNL4QossRXAbm8/+zhMMdTgo8quvvcYTIEezOyzJX3b2ep2B6JITCE626Gp/jfOe58sKzVfhN/nAILQq2KOqz7i3w3MaTJKB/U0CLatXHfE7VhzmXQOnalksoyFGIY+he+05/gB1vHgbesPP5+Q8=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Location Id" = _t, FunLoc = _t, Path = _t, Level = _t, Name = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Location Id", Int64.Type}, {"FunLoc", type text}, {"Path", type text}, {"Level", Int64.Type}, {"Name", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"FunLoc", "Location"}})
in
#"Renamed Columns"

 

//This is a disconnected table which has the same data as Locations table

PARAM Locations = ADDCOLUMNS(Locations, "Level-Location", [Level] &"-" & [Location], "Level-Name", [Level] &"-" & [Name])
 
2 REPLIES 2
rfigtree
Resolver III
Resolver III

42

Can anyone help me with the required DAX?

 

Helpful resources

Announcements
August 2022 update 768x460.jpg

Check it Out!

Click here to learn more about the August 2022 updates!

August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors