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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Guillaume_
Helper I
Helper I

Replace string and number booleans to native booleans

I have a few datasets where there's a mix of inconsistent boolean, ie Y/N, Yes/No, True/False, 1/0

I would like to convert all these fields to a genuine boolean type TRUE/FALSE

I've tried using Power Query steps but it takes a few steps and have to repeat the same process for every single field.

what would be the best approach to do this? I assume a custom function should be able to handle this easily?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Guillaume_ 

If these values you mentioned in same column, you can directly create a measure with SWITCH() to return the value. For example :

Original data :

Ailsamsft_0-1657249833117.png

Then create a measure like this 

Measure = SWITCH(TRUE(),SELECTEDVALUE('Table'[Y/N])="Y","TRUE",SELECTEDVALUE('Table'[Y/N])="N","FALSE", 
                 SELECTEDVALUE('Table'[Y/N])="Yes","TRUE",SELECTEDVALUE('Table'[Y/N])="No","FALSE",      
                 SELECTEDVALUE('Table'[Y/N])="True","TRUE",SELECTEDVALUE('Table'[Y/N])="False","FALSE",
                     SELECTEDVALUE('Table'[Y/N])="1","TRUE",SELECTEDVALUE('Table'[Y/N])="0","FALSE")

The final result is as shown :

Ailsamsft_1-1657249933497.png

If they are in different columns, then you can create measures based on the columns.

I have attached my pbix file , you can refer to it .

 

Best Regards,
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
amitchandak
Super User
Super User

@Guillaume_ , You need first make this column as Text . Convert all values True/false or 1/0 and then change data type to boolean

Power Query Replace Value: https://youtu.be/hkZhZbR7Kmk

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Guillaume_
Helper I
Helper I

Thanks the replace value function if fine but replace one value by another so it seems I have to potential run several steps per field to be converted.

Is there a way to encapsulate a set of deterministc steps that would be repeated over several fields across several table? ie a custom function?

Anonymous
Not applicable

Hi @Guillaume_ 

If these values you mentioned in same column, you can directly create a measure with SWITCH() to return the value. For example :

Original data :

Ailsamsft_0-1657249833117.png

Then create a measure like this 

Measure = SWITCH(TRUE(),SELECTEDVALUE('Table'[Y/N])="Y","TRUE",SELECTEDVALUE('Table'[Y/N])="N","FALSE", 
                 SELECTEDVALUE('Table'[Y/N])="Yes","TRUE",SELECTEDVALUE('Table'[Y/N])="No","FALSE",      
                 SELECTEDVALUE('Table'[Y/N])="True","TRUE",SELECTEDVALUE('Table'[Y/N])="False","FALSE",
                     SELECTEDVALUE('Table'[Y/N])="1","TRUE",SELECTEDVALUE('Table'[Y/N])="0","FALSE")

The final result is as shown :

Ailsamsft_1-1657249933497.png

If they are in different columns, then you can create measures based on the columns.

I have attached my pbix file , you can refer to it .

 

Best Regards,
Community Support Team _ Ailsa Tao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
November Fabric Update Carousel

Fabric Monthly Update - November 2025

Check out the November 2025 Fabric update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Users online (27)