Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
HI I have a table with column as Color as below:
Color
Red
Green
Yellow
Pink
What I need is to create a measure like this:
Color Measure
Red 1
green 2
Yellow 3
Pink 4
I hope this is simple and can be easily done, I am trying if else but unable to get the result.
Thanks
Solved! Go to Solution.
Hi @Anonymous,
You can create a measure with If() function or Switch() function, see:
Measure(IF) = IF(MAX('Table3'[Color])="Red",1,IF(MAX('Table3'[Color])="green",2,IF(MAX('Table3'[Color])="Yellow",3,IF(MAX('Table3'[Color])="Pink",4,BLANK()))))
Measure(Switch) = SWITCH(TRUE(),MAX('Table3'[Color])="Red",1,MAX('Table3'[Color])="green",2,MAX('Table3'[Color])="Yellow",3,MAX('Table3'[Color])="Pink",4,BLANK())
Best Regards,
Qiuyun Yu
Hi @Anonymous,
You can create a measure with If() function or Switch() function, see:
Measure(IF) = IF(MAX('Table3'[Color])="Red",1,IF(MAX('Table3'[Color])="green",2,IF(MAX('Table3'[Color])="Yellow",3,IF(MAX('Table3'[Color])="Pink",4,BLANK()))))
Measure(Switch) = SWITCH(TRUE(),MAX('Table3'[Color])="Red",1,MAX('Table3'[Color])="green",2,MAX('Table3'[Color])="Yellow",3,MAX('Table3'[Color])="Pink",4,BLANK())
Best Regards,
Qiuyun Yu
Hi, i´m new with P.BI, i used your formula for my problem and it worked, but i don´t understand why you use MAX with text values, ¿Could you explain it?
thanks!
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
77 | |
74 | |
57 | |
40 | |
35 |
User | Count |
---|---|
65 | |
65 | |
59 | |
53 | |
45 |