Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.