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
kkarol
Frequent Visitor

two different data types in one if

Hi

I have two columns one numeric [number] and one text [name] and i want to make an if statement with them

each if ([name] = "AANNAA") and ([number]> 140) then "Yes" else "No"

it does not work, i guess because two different data types. i always create a workaround with three steps and two conditional columns.

Is it possible to have it in one if without changing data type?

 

2 ACCEPTED SOLUTIONS
AlienSx
Super User
Super User

it works 

let
    my_table = #table(type table [name = text, number = number], {{"BBB", 150}, {"AANNAA", 145}, {"AANNAA", 135}}), 
    it_works = Table.AddColumn(my_table, "if_statement", each if ([name] = "AANNAA") and ([number]> 140) then "Yes" else "No")
in
    it_works

itworks.png

 

 

View solution in original post

PwerQueryKees
Super User
Super User

The if statement you show is fine.
What is the error you get and in what context do you use the if?

Please share your code and a screenshot of the error message.

My guess: The if returns a text, but the destination of that result does not accept text...

View solution in original post

7 REPLIES 7
v-nmadadi-msft
Community Support
Community Support

Hi @kkarol ,

As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided by the community members for the issue worked. If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

 

Thanks and regards

v-nmadadi-msft
Community Support
Community Support

Hi @kkarol ,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If the responses has addressed your query, please accept it as a solution and give a 'Kudos' so other members can easily find it.

Thank you

dufoq3
Super User
Super User

Hi @kkarol, try this:

 if [name] = "AANNAA" and Number.From([number]) > 140 then "Yes" else "No"

Note: Check this link to learn how to use my query.
Check this link if you don't know how to provide sample data.

v-nmadadi-msft
Community Support
Community Support

Hi @kkarol ,

May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.

Thank you.

kkarol
Frequent Visitor

@PwerQueryKees @AlienSx so i guess that is not a problem. i will investigate it and come back to You. Thanks for Your replies.

PwerQueryKees
Super User
Super User

The if statement you show is fine.
What is the error you get and in what context do you use the if?

Please share your code and a screenshot of the error message.

My guess: The if returns a text, but the destination of that result does not accept text...

AlienSx
Super User
Super User

it works 

let
    my_table = #table(type table [name = text, number = number], {{"BBB", 150}, {"AANNAA", 145}, {"AANNAA", 135}}), 
    it_works = Table.AddColumn(my_table, "if_statement", each if ([name] = "AANNAA") and ([number]> 140) then "Yes" else "No")
in
    it_works

itworks.png

 

 

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.