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