Forum Discussion
balar2007
5 years agoRegular Visitor
SWITCH or IF
I need to transform a case statement which i have written in spotfire to Power Bi case WHEN [Formula]~="EBOB" THEN "MOGAS" WHEN [Formula]~="G01" THEN "GASOIL" WHEN [Formula]~="G50" THEN "GASOIL" ...
mahoneypat
5 years agoMicrosoft Employee
Switch is the way to go. Here is an example with your code, but not clear if you are doing a column or measure. This assumes [Formula] is a measure. Note the Formula is first calculated in a variable so it is not recalculated multiple times.
Switch Example =
VAR vFormula = [Formula]
RETURN
SWITCH (
vFormula,
"EBOB", "MOGAS",
"G01", "GASOIL",
"G50", "GASOIL",
vFormula
)
Regards,
Pat