Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I have a column of types of fruit and want to add a score for each (Apple = 1, Banana = 2, Cherry = 3, etc.).
I've tried to create a measure thinking I could use an IF condition, but my text based fruit field doesn't return as an option.
My thought was something simple like:
If(table[fruit]="Apple") then 1
Else If(table[fruit]="Banana") then 2
Else If(table[fruit]="Cherry") then 3
How can I do something like this?
Thanks,
Geoff
Solved! Go to Solution.
Hi @geoffgarcia
it's better to create a column with SWITCH() like
Column =
SWITCH(table[fruit],
"Apple", 1,
"Banana", 2,
"Cherry", 3,
0
)
but if you still need a measure try
Column =
var _fruit = MAX(table[fruit])
RETURN
SWITCH(_fruit,
"Apple", 1,
"Banana", 2,
"Cherry", 3,
0
)
Hi @geoffgarcia ,
Create a Calculated COlumn
Concept Stage Status =
SWITCH (
TRUE (),
table[fruit] = "Apple", 1,
table[fruit] = "Banana", 2,
table[fruit] = "Cherry", 3,
BLANK ()
)
Regards,
Harsh Nathani
Hi @geoffgarcia
it's better to create a column with SWITCH() like
Column =
SWITCH(table[fruit],
"Apple", 1,
"Banana", 2,
"Cherry", 3,
0
)
but if you still need a measure try
Column =
var _fruit = MAX(table[fruit])
RETURN
SWITCH(_fruit,
"Apple", 1,
"Banana", 2,
"Cherry", 3,
0
)
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 37 | |
| 36 | |
| 32 | |
| 31 | |
| 29 |
| User | Count |
|---|---|
| 132 | |
| 86 | |
| 85 | |
| 68 | |
| 64 |