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
sonuojha1
Helper IV
Helper IV

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.

 

sonuojha1_0-1611498864617.png

 

 

Regards,

Sonu

 

2 ACCEPTED SOLUTIONS
MFelix
Super User
Super User

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.

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

Thanks Miguel. 

I have noted your comment. 

 

Regards,

Sonu

View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

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.

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Thanks Miguel. 

I have noted your comment. 

 

Regards,

Sonu

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.