Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
)
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 29 | |
| 27 | |
| 26 | |
| 23 | |
| 16 |
| User | Count |
|---|---|
| 53 | |
| 46 | |
| 38 | |
| 30 | |
| 21 |