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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Custom Column Query

Hello,

 

I have a column which has values of = "0", "1" and Empty.

 

How do I create a custom column which gives me the following information.

 

IF 

0 = Fail

1 = Pass

Empty = Pass

 

I've been trying the below - 

=IF [Attend Pass] = 1 then "Pass" else "Fail" 

 

TIA

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

M code is completely case-sensitive, so using 'IF' instead of 'if' will cause the calculation to fail. Similarly, referencing '1' instead of ' "1" ' if the value is in a text field will also fail.

Also, your condition is picking out the 1 = pass criteria first. It's simpler to pick out the 0 = Fail first, then just apply pass to 1 and null as per your requirement.

 

Try these calculations to see what works for you:

// [Attend Pass] = numeric
if [Attend Pass] = 0 then "Fail" else "Pass"

// [Attend Pass] = text
if [Attend Pass] = "0" then "Fail" else "Pass"

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

1 REPLY 1
BA_Pete
Super User
Super User

Hi @Anonymous ,

 

M code is completely case-sensitive, so using 'IF' instead of 'if' will cause the calculation to fail. Similarly, referencing '1' instead of ' "1" ' if the value is in a text field will also fail.

Also, your condition is picking out the 1 = pass criteria first. It's simpler to pick out the 0 = Fail first, then just apply pass to 1 and null as per your requirement.

 

Try these calculations to see what works for you:

// [Attend Pass] = numeric
if [Attend Pass] = 0 then "Fail" else "Pass"

// [Attend Pass] = text
if [Attend Pass] = "0" then "Fail" else "Pass"

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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