Forum Discussion

augustindelaf's avatar
augustindelaf
Impactful Individual
7 years ago
Solved

display multiple elements with SELECTEDVALUE

Hello,

 

I am using the DAX measure SELECTEDVALUE to display the value of a column that is filtered in a table visual.

But I can't find a way to display multiple elements.

 

For instance, if "France" is selected in the field 'Data'[Nationality], the DAXmeasure SELECTEDVALUE will display "France", and that is good. (SelectedNationality = SELECTEDVALUE(data[Nationality])

But if I select "France" and "Italy" in this filed, I would like that my measure displays both "France" and "Italy".

 

Any idea HOW ?

Best regards

Augustin

  • v-lili6-msft's avatar
    v-lili6-msft
    7 years ago

    hi, augustindelaf 

    Try this formula: 

    Selected PDLs=
    CONCATENATEX ( VALUES ( Data[Nationality] ) , [Nationality] , ",")

    Best Regards,

    Lin

     

  • PattemManohar's avatar
    PattemManohar
    7 years ago

    augustindelaf  Please try this in your measure..

     

    MonthSelection = 
    VAR _Count = COUNTROWS(VALUES(_Date[Month]))
    VAR _Concat = CONCATENATEX(VALUES(_Date[Month]),[Month],",")
    RETURN IF(_Count>2,"Multiple Selection",_Concat)

16 Replies

  • v-lili6-msft's avatar
    v-lili6-msft
    Community Support

    hi, augustindelaf 

    SELECTEDVALUE returns the value when the context for columnName has been filtered down to one distinct value only. Otherwise returns alternateResult.

    So you could just need to use IN and VALUES instead of SELECTEDVALUE

    For example:

    (SelectedNationality IN VALUES(data[Nationality])

     

    Best Regards,

    Lin

     

    • augustindelaf's avatar
      augustindelaf
      Impactful Individual

      v-lili6-msft could you please write the exact measure ?

      I wrote the one you gave me but it didn't work.

       

      Many thanks in advance.

      Best regards,

      Augustin

  • Hello Augustin,

     

    I think CONCATENATEX is going to do what you want. CONCATENATEX iterates over a table and concatenates a text expression evaluated for each row of the table. In particular, you can use CONCATENATEX with VALUES to concatenate distinct values from a column.

     

    You could write a measure like this to create a comma-separated string of Nationality values.

     

    SelectedNationalities =
    CONCATENATEX (
        VALUES ( data[Nationality] ),
        ", "
    )

    Is that what you were looking for?

     

    Regards,

    Owen

    • augustindelaf's avatar
      augustindelaf
      Impactful Individual

      hi 

       

      OwenAuger 

       

      It would be perfect but it doesn't work.

      My measure (exactly the one you wrote) is not in error, and it finds the field nationality but the only value that is displayed is the Comma.

       

       

      2 values selected

       

      • v-lili6-msft's avatar
        v-lili6-msft
        Community Support

        hi, augustindelaf 

        Try this formula: 

        Selected PDLs=
        CONCATENATEX ( VALUES ( Data[Nationality] ) , [Nationality] , ",")

        Best Regards,

        Lin