Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hello,
I have a table in power bi that contains some boolean values. The requestor for the report needs to see yes & no instead of true / false.
Is there a way to easily change all values of true to yes and all values of false to no?
Any help is greatly appreaciated.
Thank you!
Solved! Go to Solution.
Is it possible for you to just use SWITCH ( ) in a new calculated column?
UseSwitch = SWITCH(Table1[Column1],TRUE,"Yes",FALSE,"No")
Proud to be a Super User!
It's really very easy.
Instead of switch statements etc, all you need to do is:
1. Change the field type to Text
2. Replace values
I know this is quite old question and already have solution. But I also got into this and searched for a easy solution. I understand that DAX calculated column is a good solution, and I also think doing it in Power query might be alternate good solution. I would like to just share it here:
1. Since original column is logical TRUE/FALSE, just replacing TRUE with Yes shall not work (as @romgut suggested), because this column can only replace value with logical ones (1/0 etc).
2. So instead, add a condition column as attached picture:
3. Change this new column to Text type.
4. Remove the original column.
Its done. Just wanted to share it here....
what about replacing the values with m-query?
@ChrisMendoza
thanks but doesnt work.... error as follows
'SWITCH' does not support comparing values of type Text with values of type True/False. Consider using the VALUE or FORMAT function to convert one of the values.
what i ended up doing was creating a boolean column in power query , used this to populate yes or no on a second column (could have left it as Boolean) but people prefer yes or no thanks
@Kayak6000 - I created a sample table and my results show it works as intended. If you would like assistance with your issue please submit a question to the community (https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/td-p/1447523/jump...).
Incidently, notice [Column1] is of type 'Logical' and not 'Text'
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCgkKdVWK1YlWcnP0CYaw4EIQRiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type logical}})
in
#"Changed Type"
Column =
SWITCH(
'Table'[Column1],
TRUE(),"yes",
"no"
)
Column 2 =
SWITCH(
'Table'[Column1],
TRUE,"yes",
"no"
)
Proud to be a Super User!
Thanks @ChrisMendoza think the issue is [Column1] is of type 'Logical' and not 'Text' i will try the change type and see how i get on Regards
Is it possible for you to just use SWITCH ( ) in a new calculated column?
UseSwitch = SWITCH(Table1[Column1],TRUE,"Yes",FALSE,"No")
Proud to be a Super User!
Thank you Chris! I was able to replicate and it seems to be working smoothly.
Check out the September 2024 Power BI update to learn about new features.
Learn from experts, get hands-on experience, and win awesome prizes.
User | Count |
---|---|
113 | |
109 | |
98 | |
39 | |
30 |