Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Displaying selected field from Hierarchy slicer on a text box.

Hello Everyone,

 

I need some help in displaying selected values in my Hierarchy slicer on a text box.  I am using a Hierarchy slicer to slice and dice my data and it has 5 levels in this sequence Corporate, Global Region, Country, Reporting Region, and Location. 

 

For Example,Date.PNG if I am selected any value from the 4th level (Reporting Region) then I want the text box to display that level value on my text box.

 

 

 

 

 

 

1 ACCEPTED SOLUTION
technolog
Honored Contributor

Here is a simple pattern that returns the deepest single selection. It covers both the standard slicer and the Hierarchy Slicer visual. Replace DimGeo with your table name if needed.

Selected node name =
VAR v5 = IF(COUNTROWS(VALUES(DimGeo[Location])) = 1, SELECTEDVALUE(DimGeo[Location]))
VAR v4 = IF(COUNTROWS(VALUES(DimGeo[Reporting Region])) = 1, SELECTEDVALUE(DimGeo[Reporting Region]))
VAR v3 = IF(COUNTROWS(VALUES(DimGeo[Country])) = 1, SELECTEDVALUE(DimGeo[Country]))
VAR v2 = IF(COUNTROWS(VALUES(DimGeo[Global Region])) = 1, SELECTEDVALUE(DimGeo[Global Region]))
VAR v1 = IF(COUNTROWS(VALUES(DimGeo[Corporate])) = 1, SELECTEDVALUE(DimGeo[Corporate]))
RETURN COALESCE(v5, v4, v3, v2, v1, "All")

If you want a friendly label that includes the level name, use this

Selection label =
VAR v5 = IF(COUNTROWS(VALUES(DimGeo[Location])) = 1, SELECTEDVALUE(DimGeo[Location]))
VAR v4 = IF(COUNTROWS(VALUES(DimGeo[Reporting Region])) = 1, SELECTEDVALUE(DimGeo[Reporting Region]))
VAR v3 = IF(COUNTROWS(VALUES(DimGeo[Country])) = 1, SELECTEDVALUE(DimGeo[Country]))
VAR v2 = IF(COUNTROWS(VALUES(DimGeo[Global Region])) = 1, SELECTEDVALUE(DimGeo[Global Region]))
VAR v1 = IF(COUNTROWS(VALUES(DimGeo[Corporate])) = 1, SELECTEDVALUE(DimGeo[Corporate]))
VAR name = COALESCE(v5, v4, v3, v2, v1)
VAR level =
IF(NOT(ISBLANK(v5)), "Location",
IF(NOT(ISBLANK(v4)), "Reporting Region",
IF(NOT(ISBLANK(v3)), "Country",
IF(NOT(ISBLANK(v2)), "Global Region",
IF(NOT(ISBLANK(v1)), "Corporate", BLANK())))))
RETURN IF(ISBLANK(name), "All", level & ": " & name)

If the only thing you care about is Reporting Region, and you want the text to change only when exactly one region is selected, use this lean measure

Selected reporting region =
VAR c = COUNTROWS(VALUES(DimGeo[Reporting Region]))
RETURN IF(c = 1, SELECTEDVALUE(DimGeo[Reporting Region]), "All reporting regions")

 

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

I am not infront of my desktop but. I can give your fair idea.

You have to use pathfunction dax.

Just check out Microsoft documentation.

Thanks
Pravin
technolog
Honored Contributor

Here is a simple pattern that returns the deepest single selection. It covers both the standard slicer and the Hierarchy Slicer visual. Replace DimGeo with your table name if needed.

Selected node name =
VAR v5 = IF(COUNTROWS(VALUES(DimGeo[Location])) = 1, SELECTEDVALUE(DimGeo[Location]))
VAR v4 = IF(COUNTROWS(VALUES(DimGeo[Reporting Region])) = 1, SELECTEDVALUE(DimGeo[Reporting Region]))
VAR v3 = IF(COUNTROWS(VALUES(DimGeo[Country])) = 1, SELECTEDVALUE(DimGeo[Country]))
VAR v2 = IF(COUNTROWS(VALUES(DimGeo[Global Region])) = 1, SELECTEDVALUE(DimGeo[Global Region]))
VAR v1 = IF(COUNTROWS(VALUES(DimGeo[Corporate])) = 1, SELECTEDVALUE(DimGeo[Corporate]))
RETURN COALESCE(v5, v4, v3, v2, v1, "All")

If you want a friendly label that includes the level name, use this

Selection label =
VAR v5 = IF(COUNTROWS(VALUES(DimGeo[Location])) = 1, SELECTEDVALUE(DimGeo[Location]))
VAR v4 = IF(COUNTROWS(VALUES(DimGeo[Reporting Region])) = 1, SELECTEDVALUE(DimGeo[Reporting Region]))
VAR v3 = IF(COUNTROWS(VALUES(DimGeo[Country])) = 1, SELECTEDVALUE(DimGeo[Country]))
VAR v2 = IF(COUNTROWS(VALUES(DimGeo[Global Region])) = 1, SELECTEDVALUE(DimGeo[Global Region]))
VAR v1 = IF(COUNTROWS(VALUES(DimGeo[Corporate])) = 1, SELECTEDVALUE(DimGeo[Corporate]))
VAR name = COALESCE(v5, v4, v3, v2, v1)
VAR level =
IF(NOT(ISBLANK(v5)), "Location",
IF(NOT(ISBLANK(v4)), "Reporting Region",
IF(NOT(ISBLANK(v3)), "Country",
IF(NOT(ISBLANK(v2)), "Global Region",
IF(NOT(ISBLANK(v1)), "Corporate", BLANK())))))
RETURN IF(ISBLANK(name), "All", level & ": " & name)

If the only thing you care about is Reporting Region, and you want the text to change only when exactly one region is selected, use this lean measure

Selected reporting region =
VAR c = COUNTROWS(VALUES(DimGeo[Reporting Region]))
RETURN IF(c = 1, SELECTEDVALUE(DimGeo[Reporting Region]), "All reporting regions")

 

Helpful resources

Announcements
Users online (11,586)