f0rd42
f0rd42

Reputation: 1459

PowerQuery - Check if Column value equals true

I have build several additional columns in PowerQuery based on my source data. This includes two "TextContains" columns which only return "TRUE" or "FALSE". I now want an additional Column highlighting the different service types and used this:

if [PSTag] = "PS" then "PS" 
else if [Trainingskit] = "TrainingsKit" then "Training"
else if [Training] = "Training" then "Training"
else if [HardwareService] = "TRUE" then "HardwareService"
else if [TelephoneService] = "TRUE" then "TelephoneService" else "NonService"

It works fine for the first three IF statements, but doesn't work at all for the Columns containing only "TRUE" or "FALSE". The first three contain either e.g. "PS" or "NonPS" or "Training" or "NonTraining"

I'm sure I'm "just" missing a very fundamental here.

Any help is highly appreciated.

Upvotes: 4

Views: 34303

Answers (2)

Svitlana
Svitlana

Reputation: 1

You should write in lowercase:

...
else if [HardwareService] = "true" then "HardwareService"
else if [TelephoneService] = "true" then "TelephoneService"
...

Upvotes: 0

Mike Honey
Mike Honey

Reputation: 15027

Columns containing only TRUE or FALSE are likely the "True/False" datatype. Their values appear in italic font in the Query Preview window.

If that is the case with your [HardwareService] and [TelephoneService] columns then I would remove the quotes e.g. write something like:

... if [HardwareService] = true then ...

Upvotes: 11

Related Questions