Working with hierarchies in Slicers and selectedvalue() for titles

Hello,

I’m struggling getting the right value to display for my report.

IF a single entity is selected I want that entity value to be returned as value (see. ex. in that attached) ; although it automatically selects a group > Secteur > Division > Consolidation.

If 2 entities are selected ex. 031 and 032 then I want these 2 values to show.

These are from a DIM_Entity table in which these 5 levels are into separate columns

Could you please help me out with this formula

It sounds like you’re trying to dynamically display selected values from a hierarchical slicer in Power BI. You can achieve this using DAX formulas that handle different selection scenarios.

Here’s a general approach:

  1. Single Selection: Use SELECTEDVALUE() to return the selected entity.
  2. Multiple Selections: Use CONCATENATEX() to display multiple selected values.

Try this DAX measure:

SelectedEntityTitle =
VAR SelectedEntities = VALUES(DIM_Entity[Entity])
RETURN
IF(
    COUNTROWS(SelectedEntities) = 1,
    SELECTEDVALUE(DIM_Entity[Entity]),
    CONCATENATEX(SelectedEntities, DIM_Entity[Entity], ", ")
)

This measure will:

  • Show the selected entity if only one is chosen.
  • Display multiple selected entities separated by commas when more than one is selected.

For more details, you can check out discussions on hierarchies in slicers and selectedvalue() for titles here and here. Let me know if you need further refinements!

1 Like

Hi @CNET - Please confirm if issue is resolved based on @pranamg response or still needing any help.

Thanks
Ankit J