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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
lalumiereMike
Regular Visitor

Need help with selectedvalue within a hierarchy slicer

Hello, 

I'm looking for guidance on figuring the appropriate DAX Formula structure for the following: 
I want to leverage a slicer that contains my entity rollup structure 
Groupe Conso > Division > Secteur > Etablissement_GroupeDescription > Etablissement_ID_Description
My desired if to have a formula that returns the appropriate value of Dim_Etablissements_complet, in a way that : 

If only a value of Etablissement_ID_Description is selected it returns the Selectedvalue(Etablissement_ID_Description) 
if not all values of Etablissement_ID_Description are selected within that node (e.g. Etablissement_GroupeDescription) then it concatenates Selectedvalue(Etablissement_ID_Description) such as 031 ; 032
if (4) a group value from Etablissement_GroupeDescription is selected then it returns the Selectedvalue(Etablissement_GroupeDescription)
if (3 ) a secteur value from Secteur_Description is selected then it returns the Selectedvalue(Secteur_Description)
if (2 ) a division value from Division_Description is selected then it returns the Selectedvalue(Divison_Description)
lalumiereMike_0-1744650980538.png

Here are  my set of variables

VAR _SelectedGroupConso=SELECTEDVALUE('Dim_Etablissements_complet'[GroupeConso_Description])
VAR _SelectedDivision=SELECTEDVALUE('Dim_Etablissements_complet'[Division_Description])
VAR _SelectedSecteur=SELECTEDVALUE('Dim_Etablissements_complet'[Secteur_Description])
VAR _SelectedGroupeEtablissement=SELECTEDVALUE('Dim_Etablissements_complet'[Etablissement_GroupeDescription])
VAR _SelectedEtablissement=SELECTEDVALUE('Dim_Etablissements_complet'[Etablissement_ID_Description])

Thanks in advance for you help, 

Mike

1 ACCEPTED SOLUTION
v-pagayam-msft
Community Support
Community Support

Hi @lalumiereMike ,
Thank you for reaching out to us on Microsoft Fabric Community Forum!
Thank you @lbendlin for the prompt response!Upon my understanding,In addition, please follow the below steps.

  • Create a hierarchy in Power BI using the following columns (GroupeConso_Description, Division_Description, Secteur_Description, Etablissement_GroupeDescription, Etablissement_ID_Description)
  • Use the following measure to dynamically return the appropriate value based on the slicer selection:
     
    Selected Entity Label =
    VAR _SelectedEtablissements = VALUES('Dim_Etablissements_complet'[Etablissement_ID_Description])
    VAR _CountEtablissements = COUNTROWS(_SelectedEtablissements)

    VAR _SelectedGroupeEtablissement = SELECTEDVALUE('Dim_Etablissements_complet'[Etablissement_GroupeDescription])
    VAR _SelectedSecteur = SELECTEDVALUE('Dim_Etablissements_complet'[Secteur_Description])
    VAR _SelectedDivision = SELECTEDVALUE('Dim_Etablissements_complet'[Division_Description])
    VAR _SelectedGroupConso = SELECTEDVALUE('Dim_Etablissements_complet'[GroupeConso_Description])

    RETURN
    SWITCH(
        TRUE(),
       
        // Only 1 Etablissement selected
        _CountEtablissements = 1,
            SELECTEDVALUE('Dim_Etablissements_complet'[Etablissement_ID_Description]),

        // Multiple Etablissements selected AND no higher-level selection
        _CountEtablissements > 1
            && ISBLANK(_SelectedGroupeEtablissement)
            && ISBLANK(_SelectedSecteur)
            && ISBLANK(_SelectedDivision)
            && ISBLANK(_SelectedGroupConso),
            CONCATENATEX(
                _SelectedEtablissements,
                'Dim_Etablissements_complet'[Etablissement_ID_Description],
                " ; "
            ),

        // Higher levels: check in order of hierarchy
        NOT ISBLANK(_SelectedGroupeEtablissement), _SelectedGroupeEtablissement,
        NOT ISBLANK(_SelectedSecteur), _SelectedSecteur,
        NOT ISBLANK(_SelectedDivision), _SelectedDivision,
        NOT ISBLANK(_SelectedGroupConso), _SelectedGroupConso,

        "No Selection"
    )
     
  • Add this measure to a cardvisual to reflect the user’s slicer selection. The measure will adapt as users drill down or select multiple items.Refer the attached screenshot and file for your reference.

    vpagayammsft_0-1744701239216.png

     

If this solution meets your requirement,consider accepting it as solution.

Regards,
Pallavi.

View solution in original post

5 REPLIES 5
v-pagayam-msft
Community Support
Community Support

Hi @lalumiereMike ,
I wanted to follow up on our previous suggestions regarding the issue you are facing. We would like to hear back from you to ensure we can assist you further. If our response has addressed your query, please accept it as a solution and give a ‘Kudos’ so other members can easily find it. 
Thank you.

v-pagayam-msft
Community Support
Community Support

Hi @lalumiereMike ,

As we have not received a response from you yet, I would like to confirm whether you have successfully resolved the issue or if you require further assistance. If the issue has been resolved, please mark the helpful reply as a "solution" to indicate that the question has been answered and to assist others in the community.

Thank you for your cooperation. Have a great day.

v-pagayam-msft
Community Support
Community Support

Hi @lalumiereMike ,
I wanted to follow up on our previous suggestions regarding the issue you are facing. We would like to hear back from you to ensure we can assist you further. If our response has addressed your query, please accept it as a solution and give a ‘Kudos’ so other members can easily find it. 
Thank you

v-pagayam-msft
Community Support
Community Support

Hi @lalumiereMike ,
Thank you for reaching out to us on Microsoft Fabric Community Forum!
Thank you @lbendlin for the prompt response!Upon my understanding,In addition, please follow the below steps.

  • Create a hierarchy in Power BI using the following columns (GroupeConso_Description, Division_Description, Secteur_Description, Etablissement_GroupeDescription, Etablissement_ID_Description)
  • Use the following measure to dynamically return the appropriate value based on the slicer selection:
     
    Selected Entity Label =
    VAR _SelectedEtablissements = VALUES('Dim_Etablissements_complet'[Etablissement_ID_Description])
    VAR _CountEtablissements = COUNTROWS(_SelectedEtablissements)

    VAR _SelectedGroupeEtablissement = SELECTEDVALUE('Dim_Etablissements_complet'[Etablissement_GroupeDescription])
    VAR _SelectedSecteur = SELECTEDVALUE('Dim_Etablissements_complet'[Secteur_Description])
    VAR _SelectedDivision = SELECTEDVALUE('Dim_Etablissements_complet'[Division_Description])
    VAR _SelectedGroupConso = SELECTEDVALUE('Dim_Etablissements_complet'[GroupeConso_Description])

    RETURN
    SWITCH(
        TRUE(),
       
        // Only 1 Etablissement selected
        _CountEtablissements = 1,
            SELECTEDVALUE('Dim_Etablissements_complet'[Etablissement_ID_Description]),

        // Multiple Etablissements selected AND no higher-level selection
        _CountEtablissements > 1
            && ISBLANK(_SelectedGroupeEtablissement)
            && ISBLANK(_SelectedSecteur)
            && ISBLANK(_SelectedDivision)
            && ISBLANK(_SelectedGroupConso),
            CONCATENATEX(
                _SelectedEtablissements,
                'Dim_Etablissements_complet'[Etablissement_ID_Description],
                " ; "
            ),

        // Higher levels: check in order of hierarchy
        NOT ISBLANK(_SelectedGroupeEtablissement), _SelectedGroupeEtablissement,
        NOT ISBLANK(_SelectedSecteur), _SelectedSecteur,
        NOT ISBLANK(_SelectedDivision), _SelectedDivision,
        NOT ISBLANK(_SelectedGroupConso), _SelectedGroupConso,

        "No Selection"
    )
     
  • Add this measure to a cardvisual to reflect the user’s slicer selection. The measure will adapt as users drill down or select multiple items.Refer the attached screenshot and file for your reference.

    vpagayammsft_0-1744701239216.png

     

If this solution meets your requirement,consider accepting it as solution.

Regards,
Pallavi.

lbendlin
Super User
Super User

SELECTEDVALUE work ONLY if you have a SINGLE value selected.  That is not the case in your scenarios.  Use VALUES instead.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.