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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
dasare8890
Frequent Visitor

Dynamic Titles with Multiple Selections

I want to be able to do the following 

 

1. When no selection is made on a slicer: Return "All"

2. When 1-3 selections  are made on the slicer: Return "text1,text2,text3"

3. When 4 or more selections are on the slicer: Return "text1,text2,text3, ....."

 

The DAX below works for 2 and 3 but not 1. When no selection is made on the slicer i get "text1,text2,text3, ....." instead.

 

List of Lookup values =
VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('Column')
VAR __MAX_VALUES_TO_SHOW = 5
RETURN
IF(ISFILTERED(Column),
    IF(
        __DISTINCT_VALUES_COUNT > __MAX_VALUES_TO_SHOW,
        CONCATENATE(
            CONCATENATEX(
                TOPN(
                    __MAX_VALUES_TO_SHOW,
                    VALUES(Column),
                    Column,
                    ASC
                ),
                Column,
                ",",
                Column,
                ASC
            ),
            ", ..."
        ),
        CONCATENATEX(
            VALUES(Column),
            Column,
            ", ",
            Column,
            ASC
        )
    )
    , "All"
)

 

 

 

1 ACCEPTED SOLUTION
bolfri
Super User
Super User

It works IMO.

 

List of Lookup values =
VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('Sample'[Column])
VAR __MAX_VALUES_TO_SHOW = 3
RETURN
IF(ISFILTERED('Sample'[Column]);
    IF(
        __DISTINCT_VALUES_COUNT > __MAX_VALUES_TO_SHOW;
        CONCATENATE(
            CONCATENATEX(
                TOPN(
                    __MAX_VALUES_TO_SHOW;
                    VALUES('Sample'[Column]);
                    'Sample'[Column];
                    ASC
                );
                'Sample'[Column];
                ", ";
                'Sample'[Column];
                ASC
            );
            "..."
        );
        CONCATENATEX(
            VALUES('Sample'[Column]);
            'Sample'[Column];
            ", ";
            'Sample'[Column];
            ASC
        )
    );
    "All"
)
 
Scenario 1: No selection
bolfri_0-1671580850455.png

 

Scenario 2: 2 selection

bolfri_1-1671580880289.png

Scenario 3: More than 3

bolfri_2-1671580926901.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

3 REPLIES 3
v-henryk-mstf
Community Support
Community Support

Hi @dasare8890 ,

 

Whether the advice given by @bolfri  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

bolfri
Super User
Super User

It works IMO.

 

List of Lookup values =
VAR __DISTINCT_VALUES_COUNT = DISTINCTCOUNT('Sample'[Column])
VAR __MAX_VALUES_TO_SHOW = 3
RETURN
IF(ISFILTERED('Sample'[Column]);
    IF(
        __DISTINCT_VALUES_COUNT > __MAX_VALUES_TO_SHOW;
        CONCATENATE(
            CONCATENATEX(
                TOPN(
                    __MAX_VALUES_TO_SHOW;
                    VALUES('Sample'[Column]);
                    'Sample'[Column];
                    ASC
                );
                'Sample'[Column];
                ", ";
                'Sample'[Column];
                ASC
            );
            "..."
        );
        CONCATENATEX(
            VALUES('Sample'[Column]);
            'Sample'[Column];
            ", ";
            'Sample'[Column];
            ASC
        )
    );
    "All"
)
 
Scenario 1: No selection
bolfri_0-1671580850455.png

 

Scenario 2: 2 selection

bolfri_1-1671580880289.png

Scenario 3: More than 3

bolfri_2-1671580926901.png

 





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Thank you Bolfri!

 

looks like I had "Filters on all pages" which was preventing this to work on my end. 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.