0
votes

I'm trying to create a column which classifies another column of growth rates into text, specifically:

Low (<20%), Medium (20-50%), High (50-100%) and Very High (>100%) 

To do this I'm using the switch function:

Growth Category = 
SWITCH( TRUE(),
('Priority List'[Observed passenger growth in last 10 years]) < .2 , "Low",
('Priority List'[Observed passenger growth in last 10 years]) > .2 & ('Priority List'[Observed passenger growth in last 10 years]) < .5, "Medium", 
('Priority List'[Observed passenger growth in last 10 years]) > .5 & ('Priority List'[Observed passenger growth in last 10 years]) < 1, "High", 
('Priority List'[Observed passenger growth in last 10 years]) > 1, "Very High")

But Power Bi keeps returning this error - DAX comparison operations do not support comparing values of type Number with values of type Text. Consider using the VALUE or FORMAT function to convert one of the values.

Any ideas to fix this?

2
No use the SWITCH, but the logic AND is double && - OscarLar

2 Answers

0
votes

Use the SWITCH but you can clean it like this:

rowth Category = 
SWITCH( 
    TRUE(),
    'Priority List'[Observed passenger growth in last 10 years] < .2 , "Low",
    'Priority List'[Observed passenger growth in last 10 years] < .5, "Medium", 
    'Priority List'[Observed passenger growth in last 10 years] < 1, "High", 
    "Very High"
)
0
votes

you nested if in scenarios like this.

Growth Category = 
IF('Priority List'[Observed passenger growth in last 10 years]) < .2 , "Low",
IF('Priority List'[Observed passenger growth in last 10 years]) < .5, "Medium", 
IF('Priority List'[Observed passenger growth in last 10 years]) < 1, "High", "Very High")))