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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
fiveone
Helper II
Helper II

Turning a column into a measure

Conditionnal formating, color saturation and so on require a measure, not a column, to be able to add a touch of color to my visualization.

So I need to turn text column into measures. What is the best way to do that?

 

I tried the following but don't really like it

 

columnToMeasure =
SWITCH (
MAX([Column]);"A";1;
MAX([Column]);"B";2;
MAX([Column]);"C";3;
0
)

 

1 ACCEPTED SOLUTION
Vvelarde
Community Champion
Community Champion

@fiveone

 

The error message is because in a total Row is using all the rows in the filter context.

 

So to avoid this message you can use IF(HASONEVALUE('Unique Won....'[PROFILE OF CANDIDATE]), SWITCH.....

 

Let me know if works




Lima - Peru

View solution in original post

5 REPLIES 5
Vvelarde
Community Champion
Community Champion

@fiveone

 

columnToMeasure =
SWITCH (
VALUES(Table1[Column]);"A";1;"B";2;"C";3;0)




Lima - Peru

Thank you for clarifying the right use of the switch function 😉

 

Unfortunately I still end up with the following error

 

2017-02-08 10_43_05-Staffing Dashboard - Power BI Desktop.png

 

It does work with MAX though, but I am not a big fan of this trick ;-(

 

Profile ID = 
SWITCH (		
MAX('Unique Won SR Details'[PROFILE OF CANDIDATE]);"JR";1;"INT";2;"SR";3;0
)
Vvelarde
Community Champion
Community Champion

@fiveone

 

The error message is because in a total Row is using all the rows in the filter context.

 

So to avoid this message you can use IF(HASONEVALUE('Unique Won....'[PROFILE OF CANDIDATE]), SWITCH.....

 

Let me know if works




Lima - Peru

Nice!

 

You are clearly da man!

 

The following works like a charm

 

Profile ID = 
IF(HASONEVALUE('Unique Won SR Details'[PROFILE OF CANDIDATE]);SWITCH (VALUES('Unique Won SR Details'[PROFILE OF CANDIDATE]);"JR";1;"INT";2;"SR";3;0);0)

I think that will successfully create a measure but not sure if that will work in the context of a visual. I think that will depend.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors