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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
elidman
Frequent Visitor

Get slicer selected member keys as measure

Hi,

I'm would like to generate a concatenated string of selected members (keys) from a slicer as a measure text string.

The end-user pick a few companies (CompanyName) in a slicer and I want the measure to return a string of CompanyKeys of the selected companies.

 

I have tried this;

VAR Company = IF(ISFILTERED(DimCompany[CompanyKey]) ,
                "CompanyKey = " & CONCATENATEX(ALLSELECTED(DimCompany[CompanyKey]) , DimCompany[CompanyKey] , " , ") & CR_LF , "")

It works great, if the slicer show the surugat key "CompanyKey". But the user do not understand what the number 12344321 means... We need to use the CompanyName in the slicer.

 

And I have tried this;

Selected filters = if(HASONEFILTER(DimCompany[CompanyName]), Values(DimCompany[CompanyKey]))
This is exactly what I want to do, except I want the user to be able to do multi-select in the slicer, which HASONEFILTER do not support.
 
Any help would be appriciated,
 
/Erik
 
 
1 ACCEPTED SOLUTION
v-binbinyu-msft
Community Support
Community Support

Hi @elidman ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1670564058337.png

2. create a measure with below dax formula

Measure =
VAR _str =
    CONCATENATEX ( 'Table', [Company Name], "," )
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table'[Company Key] ),
        CONTAINSSTRING ( _str, 'Table'[Company Name] )
    )
RETURN
    IF (
        ISFILTERED ( 'Table'[Company Name] ),
        CONCATENATEX ( tmp, [Company Key], "
" )
    )

3. add a sclicer with "Table[Company Name]", add a card visual with measure

Animation24.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-binbinyu-msft
Community Support
Community Support

Hi @elidman ,

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1670564058337.png

2. create a measure with below dax formula

Measure =
VAR _str =
    CONCATENATEX ( 'Table', [Company Name], "," )
VAR tmp =
    CALCULATETABLE (
        VALUES ( 'Table'[Company Key] ),
        CONTAINSSTRING ( _str, 'Table'[Company Name] )
    )
RETURN
    IF (
        ISFILTERED ( 'Table'[Company Name] ),
        CONCATENATEX ( tmp, [Company Key], "
" )
    )

3. add a sclicer with "Table[Company Name]", add a card visual with measure

Animation24.gif

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@elidman , not very clear, but if you have company name column too

 

VAR Company = IF(ISFILTERED(DimCompany[CompanyKey]) ,
"CompanyKey = " & CONCATENATEX(DimCompany, DimCompany[CompanyKey] & " - " & DimCompany[CompanyName] , " , ") & CR_LF , "")

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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