Forum Discussion
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?
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_worksThe 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...
7 Replies
- AlienSxSuper 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 - PwerQueryKeesSuper 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...
- kkarolFrequent Visitor
PwerQueryKees AlienSx so i guess that is not a problem. i will investigate it and come back to You. Thanks for Your replies.
- v-nmadadi-msftCommunity 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.
- v-nmadadi-msftCommunity 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 - v-nmadadi-msftCommunity 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