Forum Discussion
geoffgarcia
6 years agoHelper I
Scoring text
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 base...
- 6 years ago
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 )
az38
6 years agoCommunity Champion
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
)