Forum Discussion

bobby27's avatar
bobby27
Frequent Visitor
5 years ago
Solved

How to create a label field based on selected fields

 

I would like the matrix on the right hand side of the page to always show a single row and be dynamically based on the selection in the left hand table e.g. to show Overall or Australia or Australia - Large Customer or Australia - Large Customer - Alonso, Danny according to the selection. What DAX formula would I need to use to do this please?

 

 

 

  • How about something like this?

    My test data


    Result. I used a normal table on the right.


    It's not perfect ie. if selecting a "country" with a single item in it. If I select "a" it will show "x". But maybe this would work for you?

    pbi

  • bobby27 

    Give this a try.

    Label = 
    VAR _Country = SELECTEDVALUE('Customer'[Country])
    VAR _Category = SELECTEDVALUE('Customer'[Category])
    VAR _Name = SELECTEDVALUE('Customer'[Name])
    RETURN 
    COMBINEVALUES(" ",_Country,_Category,_Name)

     

4 Replies

  • bobby27 

    Give this a try.

    Label = 
    VAR _Country = SELECTEDVALUE('Customer'[Country])
    VAR _Category = SELECTEDVALUE('Customer'[Category])
    VAR _Name = SELECTEDVALUE('Customer'[Name])
    RETURN 
    COMBINEVALUES(" ",_Country,_Category,_Name)

     

    • bobby27's avatar
      bobby27
      Frequent Visitor

      Thanks JD, this is a great solution, you've saved me hours of frustration.

  • Gabriel_Walkman's avatar
    Gabriel_Walkman
    Icon for Continued Contributor rankContinued Contributor

    How about something like this?

    My test data


    Result. I used a normal table on the right.


    It's not perfect ie. if selecting a "country" with a single item in it. If I select "a" it will show "x". But maybe this would work for you?

    pbi

    • bobby27's avatar
      bobby27
      Frequent Visitor

      Thanks Gabriel, this works very well for me.