What I am doing with the DAX below is to only show the concatenation of values if a value is filtered. If nothing is filtered (Selected) then display text to show that nothing has been selected, otherwise display in a concatenation what has been selected.

NOTE: If you individually have to select each item, it is still being filtered so it will show all the values concatenated.

Selected User =
VAR ConCat =
    CALCULATE (
        CONCATENATEX (
            VALUES ( 'Power BI Audit Log'[User] ),
            'Power BI Audit Log'[User],
            ","
        )
    )
VAR IsItFiltered =
    IF ( ISFILTERED ( 'Power BI Audit Log'[User] ), ConCat, "No Users Selected" )
RETURN
    IsItFiltered

 

  • What is happening above with the Variable called “ConCat” is where I am concatenating the items from the ‘PowerBI Audit Log’ table and using the [User] column.
  • Then in the next Variable called “IsItFiltered” I am using the IF and ISFILTERED DAX function to evaluate if the [User] column is being filtered.
    • If it is being filtered then return the previous Variable called “ConCat” otherwise return “No Users Selected”
  • And the final piece is where I am returning the output from the IsItFiltered Variable
  • This is what it looks like when No users are selected
  • And then when two users are selected

As always if there are any questions please leave them in the comments below.

2 thoughts on “DAX – Concatenating Values only when values are selected”

  1. Thanks. How do you change the concatenatex formula so that concatenate number in the order you selected them. I’m selecting 5 then 1 then 4, but concatenatex returns 145 – thus sorting the selected values.
    Can you please assist?

    1. Hi there

      As far as I am aware currently it appears to sort it by the number value.

      What happens if you change it from Number to Text and try sorting?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.