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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

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
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.