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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RyotNomad
Frequent Visitor

Use an if statement to replace values returned by a table

I have a table with a column that contains only 1 or 0. However when I put this into my pie chart my legend shows 1 and 0. I cannot change the values in the table adn I'd prefer not to create a new table. I'm new to DAX so I tried this:

 

Measure = IF('applicant'[col] = 1, "Yes", "No")

 

But that doesn't work. Could someone guide me on how to fix this?

7 REPLIES 7
az38
Community Champion
Community Champion

Hi @RyotNomad 

try to create a Column with the same statement, not a measure 


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi. Could you show me how the DAX would look? I've clicked create new column and then used col = IF(Applicant[col], "Yes","No) but I get an error on the Yes saying it's invalid

az38
Community Champion
Community Champion

@RyotNomad 

you have a good and correct statement

 = IF('applicant'[col] = 1, "Yes", "No")

please, show text of Error


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

The syntax for "Yes" is incorrect. (DAX(IF( (Applicant[X6_13]) = 1. "Yes", "No"))).
 
 
My actual column name is X6_13. I don't know why it's putting a full stop after the 1. It's clearly a comma in my DAX statement
 
My exact Code:
Column= IF( (Applicant[X6_13]) = 1, "Yes", "No")
Anonymous
Not applicable

Hi @RyotNomad,

What type of value existed in your 'x6_13' field? Please check it to use the correct value in your if statement: (you can't directly use equal operator to compare with text and number value)

Number version:

Column =
IF ( Applicant[X6_13] = 1, "Yes", "No" )

Text version:

Column =
IF ( Applicant[X6_13] = "1", "Yes", "No" )

Notice: please also check your calculated column data type if it does not recognize as a text value.

If above not helps, can you please share more detail information about your scenario? 

How to Get Your Question Answered Quickly 

Regards,

Xiaoxin Sheng

Unfortunately neither of those worked. 

 

I'm not sure what you mean by the calcualted column data type being recognized as a text value.

 

I've included a screenshot of the data.

 

https://imgur.com/a/c4VFVN4

 

Every table is linked to applicant via foreign id

Anonymous
Not applicable

HI @RyotNomad,

Table fields can't direct use in measure formula, it can calculate and compare with aggregate values do you need to use aggregate functions to pack your table fields. (e.g. max, min, sum...)

Power BI DAX Aggregate Functions 

Measure=
IF ( max(Applicant[X6_13]) = 1, "Yes", "No" )

In addition, I'd like to suggest you take a look at the following blog about the difference between the calculated column and measure to help you know more about the difference and usage of these calculated fields:

Calculated Columns and Measures in DAX 

Regards,

Xiaoxin Sheng

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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