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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
P_D_G
Resolver III
Resolver III

Power Query: Find if value is negative only in 1 out of 2 columns

Hi all,

 

I have a table with similar data structure as below. I'd like to add anothe column which tells me if only one of the values in columns Num1 or Num2 is negative (rows 3 & 4 in the table below). Is there any way to do this with operators? So something like OR combined with NOT AND?

 

 

IDNum1Num2

1

100
2-4-4
3-28
4100-0.5

 

Thanks,

PDG

4 REPLIES 4
amitchandak
Super User
Super User

@P_D_G , A column like this in power query

if [Num1]<0 or [Num2]<0 then 1 else 0

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Hi @amitchandak,

 

Unfortunatelly your answer is not correct as this will return 1 in case of the 2nd row where both of the values are nagtive. Again, I'm only curious in rows where ONLY 1 of the values is negative.

Please read the description more carefully before answering a question.

 

Thanks,

PDG

 

@P_D_G , Sorry for that. Let me try again 

 

if ([Num1]<0 and [Num2]>=0) or ([Num1]>=0 and [Num2]<0)  then 1 else 0

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

No worries, that's all right!

Your solution is correct and now it's my turn to apologise as I wasn't 100% clear with my question.

I'm looking for a more general solution because the above works fine in this specific case however gets complicated if you have not 2 but 3 or more columns to compare.

Any idea how to make this more simple/general/suitable for comapring more numbers?

 

Thanks

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.