March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe 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
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?
ID | Num1 | Num2 |
1 | 10 | 0 |
2 | -4 | -4 |
3 | -2 | 8 |
4 | 100 | -0.5 |
Thanks,
PDG
@P_D_G , A column like this in power query
if [Num1]<0 or [Num2]<0 then 1 else 0
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
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
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
129 | |
90 | |
75 | |
58 | |
53 |
User | Count |
---|---|
200 | |
104 | |
101 | |
67 | |
55 |