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
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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

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
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors