cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
donghoonkim1226
Frequent Visitor

Change tables boolean value from true/false to yes/no

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!

1 ACCEPTED SOLUTION
ChrisMendoza
Super User
Super User

@donghoonkim1226,

 

Is it possible for you to just use SWITCH ( ) in a new calculated column?


UseSwitch = SWITCH(Table1[Column1],TRUE,"Yes",FALSE,"No") 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



View solution in original post

7 REPLIES 7
mahenkj2
Resolver III
Resolver III

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:

43.PNG

3. Change this new column to Text type.

4. Remove the original column.

 

Its done. Just wanted to share it here....

romgut
Advocate II
Advocate II

what about replacing the values with m-query?

Kayak6000
Frequent Visitor

@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.

Active  = SWITCH('DXXXXX REGISTER'[ACTIVE],TRUE,"Yes",FALSE,"No")

 

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"
)

 

image.png






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

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 

ChrisMendoza
Super User
Super User

@donghoonkim1226,

 

Is it possible for you to just use SWITCH ( ) in a new calculated column?


UseSwitch = SWITCH(Table1[Column1],TRUE,"Yes",FALSE,"No") 

 






Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

Proud to be a Super User!



Thank you Chris! I was able to replicate and it seems to be working smoothly.

Helpful resources

Announcements
May 23 2022 epsiode 5 without aka link.jpg

The Power BI Community Show

Welcome to the Power BI Community Show! Jeroen ter Heerdt talks about the importance of Data Modeling.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

Power BI Dev Camp Session 22 with aka link 768x460.jpg

Check it out!

Mark your calendars and join us on Thursday, May 26 at 11a PDT for a great session with Ted Pattison!

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!