i'd like to put in a formula that shows whether certain cells are relevant or not

bigdan

Well-known Member
Joined
Oct 5, 2009
Messages
840
Office Version
  1. 2013
Platform
  1. Windows
Hello all.

Please see sample data below. This is cols A & B. In Col C I'd like to paste a formula which tells me if this contract is relevant or not.

A contract is relevant if it has both a positive amount and a negative amount associated with it. So Contract ABC is relevant because it has both a +5 and a -6 associated with it. The other 2 are not because they have either all negs or all positives.

Btw contracts could appear as many as 50 times. I only showed 2 instances here as an example.

This is the formula I have so far. It almost works but not exactly. With this formula it would show the first row with Contract ABC as not relevant and the second one as relevant. I need both to show up as relevant.

=IF(AND(COUNTIFS($A:$A,$A2,$b:$b,"<0"),COUNTIFS($A:$A,$A2,$b:$b,">0")),"Yes","No")

Would appreciate any help!




ContractAmt
ABC
5​
DEF
-3​
DEF
-4​
GHI
7​
ABC
-6​
 

Excel Facts

Create a chart in one keystroke
Select the data and press Alt+F1 to insert a default chart. You can change the default chart to any chart type
That formula works fine for me
+Fluff 1.xlsm
ABC
1ContractAmt
2ABC5Yes
3DEF-3No
4DEF-4No
5GHI7No
6ABC-6Yes
Main
Cell Formulas
RangeFormula
C2:C6C2=IF(AND(COUNTIFS($A:$A,$A2,$B:$B,"<0"),COUNTIFS($A:$A,$A2,$B:$B,">0")),"Yes","No")


Is col B a formula or hard values?
 
Upvote 0
Untested, try
Excel Formula:
=IF(COUNTIFS(A:A,A2,B:B,IF(B2>0,"<0",">0")),"Yes","No")
 
Upvote 0
Solution
You're right! It does work properly in the dataset I attached. Not sure why, since in the working file it doesn't. Here's a screenshot.

As you can see here, the first time the contract is mentioned it's considered not relevant and it's only in the second row onwards that it's considered relevant.




1631900607585.png
 
Upvote 0
Untested, try
Excel Formula:
=IF(COUNTIFS(A:A,A2,B:B,IF(B2>0,"<0",">0")),"Yes","No")
Works! Thanks very much :)

Edit - I'm not finding the 'mark as solution' button next to your post soooo not sure what to do.
Edit 2 - nevermind, i see it on the far far right. thanks for your help!
 
Upvote 0
Glad we could help & thanks for the feedback.
 
Upvote 0
Maybe @Fluff can see something that I don't, but I'm failing to see why one would work but not the other. It might be a good idea to look into it a little more in case it is returning the correct results by fluke more than accuracy.
 
Upvote 0

Forum statistics

Threads
1,214,800
Messages
6,121,641
Members
449,044
Latest member
hherna01

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top