Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Resident Rockstar
Resident Rockstar

@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

8 REPLIES 8
Peter52912
New Member

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

mahenkj2
Solution Sage
Solution Sage

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 III
Advocate III

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
Resident Rockstar
Resident Rockstar

@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
Sept PBI Carousel

Power BI Monthly Update - September 2024

Check out the September 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

Sept NL Carousel

Fabric Community Update - September 2024

Find out what's new and trending in the Fabric Community.

Top Kudoed Authors