hIlary
hIlary

Reputation: 85

Power Bi Custom Column funtion

In MQuery, I'm trying to create a custom column. If another column has a value of 1 through 5 then the value in new column will be some text. It's given me a Token Else expected error.

=if[#"Chair Independence Level"] = "1" then "Same Product Line" 
else if[#"Chair Independence Level"]= "2" then "Different Product Line" 
else if[#"Chair Independence Level"]= "3" then "Different Business Area" 
else if[#"Chair Independence Level"]= "4" then "Different Sector" 
else if [#"Chair Independence Level"]= "5" then "Not an Employee"

Does anyone know how to fix the problem or what I should change my code to?

Upvotes: 0

Views: 69

Answers (2)

CR7SMS
CR7SMS

Reputation: 2584

The IF condition in Power query needs to be capped off with an ELSE statement. Just add the ELSE and you should be good to go:

=if[#"Chair Independence Level"] = "1" then "Same Product Line" 
else if[#"Chair Independence Level"]= "2" then "Different Product Line" 
else if[#"Chair Independence Level"]= "3" then "Different Business Area" 
else if[#"Chair Independence Level"]= "4" then "Different Sector" 
else if [#"Chair Independence Level"]= "5" then "Not an Employee"
else "NA"

If the #"Chair Independence Level" field is numeric, then:

=if[#"Chair Independence Level"] = 1 then "Same Product Line" 
else if[#"Chair Independence Level"]= 2 then "Different Product Line" 
else if[#"Chair Independence Level"]= 3 then "Different Business Area" 
else if[#"Chair Independence Level"]= 4 then "Different Sector" 
else if [#"Chair Independence Level"]= 5 then "Not an Employee"
else "NA"

Upvotes: 1

Aldert
Aldert

Reputation: 4323

You are working on the mQuery side of powerby so no DAX.

You are missing your last else statement:

else if [#"Chair Independence Level"]= "5" then "Not an Employee" ELSE "the other"

Upvotes: 1

Related Questions