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
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.


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.