Forum Discussion

sonuojha1's avatar
sonuojha1
Icon for Helper IV rankHelper IV
5 years ago
Solved

How to use text columns in Measure?

Hello All,

 

I have a small scenario, where I would like to group the nationality into below categories.

If Nationality="Indian" then "A1"

if Nationality = "Australian" then "A2"

If Nationality = "American" then "A3"

else "Other"

How would acheive it by using DAX measure. 

Kindly note, this can be achieved by adding group to the table, but I want to achieve this by measure.

 

 

 

Regards,

Sonu

 

  • Hi sonuojha1 ,

     

    You can add the following measure:

    Nationality group =
    SWITCH (
        SELECTEDVALUE ( Table[Nationality] ),
        "Indian", "A1",
        "Australian", "A2",
        "American", "A3",
        "Other"
    )

     

    Be aware that being a measure you need to have the nationality on your visualization otherwise these will not work properly, further more since it's a measure you cannot use it has a axis on visualizations or columns in a matrix visualization.

     

  • Thanks Miguel. 

    I have noted your comment. 

     

    Regards,

    Sonu

2 Replies

  • Hi sonuojha1 ,

     

    You can add the following measure:

    Nationality group =
    SWITCH (
        SELECTEDVALUE ( Table[Nationality] ),
        "Indian", "A1",
        "Australian", "A2",
        "American", "A3",
        "Other"
    )

     

    Be aware that being a measure you need to have the nationality on your visualization otherwise these will not work properly, further more since it's a measure you cannot use it has a axis on visualizations or columns in a matrix visualization.

     

    • sonuojha1's avatar
      sonuojha1
      Icon for Helper IV rankHelper IV

      Thanks Miguel. 

      I have noted your comment. 

       

      Regards,

      Sonu