Hi All,
I’m trying to create a simple conditional column noted below, and instead of the values true and false that my code specified, the values PQ assigns are 0 and 1.
Explicitly changing the type in a next step doesn’t return the values to true or false.
= Table.AddColumn(Entity, “In Scope?”, each if Text.StartsWith([Short description], “10P Monitor Project”) then true else false, type logical)
ChatGPT’s suggested solution of wrapping the if statement in a Logical.From command didn’t work either. It suggested other workarounds too that haven’t worked.
I’m trying to understand why I have to jump through such hoops to do something that seems very elementary and that’s worked in other datasets. Can you see something I’m missing, or suggest a workaround?
Postscript: I finally got this to work as shown below, but I’d like to understand why my original expression resulted in 0s and 1s.
Custom= Table.AddColumn(Entity, “In Scope?”, each if Text.StartsWith([Short description], “10P Monitor Project”) then “true” else “false”),
ChangedType = Table.TransformColumnTypes(Custom,{“In Scope?”, Logical.Type})
Hi @mspanic
I appreciate your providing a perspective that the 1/0 values could actually be a better option than TRUE/FALSE.
I’ll have to dig deeper, I guess, to understand the ramifications of 1/0 vs. TRUE/FALSE. When I tried to proceed with the 1/0 values, I ran into challenges when I’d filter, but maybe there are workarounds I didn’t explore. I also wonder why TRUE/FALSE seems to be the more common use.
Well, I figured out a workaround as I wrote at the end of my post, but I’d still like to hear from anyone who can enlighten me why PQ “insisted” on 1/0 this time, whereas it hasn’t usually, and if there’s a better way to change to TRUE/FALSE when that’s the requirement.