Filter option on multiple columns with condition

rex759

Well-known Member
Joined
Nov 8, 2004
Messages
608
Office Version
  1. 365
Platform
  1. Windows
The goal is to filter out rows to exclude duplicate Model numbers that have a total Variance of zero.

For example, in the range below, Locations 1 & 2 have the same Model number and the total Variance is zero. I want to filter or exclude them from the sample.
Rows 3, 4 & 5 have the same model number but only rows 3 & 5 has a total zero variance. I would exclude 3 & 5 but keep row 4.

The yellow highlighted rows are the ones I want to exclude

The results can be displayed in another column, filtered in place or just highlight rows that meet the criteria.

I can set up the sheet with helper columns as needed. I just don’t know where to begin.

Any advice is appreciated

current_discrepancies_202308120305.xlsx
ABC
1LocationModelVariance
2111126
32111-26
4322218
5422215
65222-18
7633360
87444345
98444-345
10955550
111066667
Sheet1
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Hi Rex,
You may be able to achieve what you're after with a sumif as a helper
so in column D, starting at D2 put
Excel Formula:
=SUMIF(B:B,B2,C:C)
then in column E, starting at E2
Excel Formula:
=IF(D2=C2,"Keep","Remove")
Copy those down and you'll have "Keep" next to the rows you have specified.
This will fall over if you have more complex number in the variance column.
Might be a start anyway, it works for your sample
 
Upvote 0
Try this, perhaps? It assumes there won't be 26, -26 and 26 again for a particular model, which might be a terrible assumption.

Book13
ABCDEFG
1LocationModelVariance
2111126422215
32111-26633360
4322218955550
54222151066667
65222-18
7633360
87444345
98444-345
10955550
111066667
Sheet1
Cell Formulas
RangeFormula
E2:G5E2=FILTER(A2:C11,ISNUMBER(XMATCH(B2:B11&C2:C11,INDEX(UNIQUE(ABS(B2:C11),,1),0,1)&INDEX(UNIQUE(ABS(B2:C11),,1),0,2))))
Dynamic array formulas.
 
Upvote 0
Thank you for the replies. I apologized that I didn't realized the last row of my chart did not post. Location 11 has another entry of the same model number and the same variance. Since the sum of the variance for model 10 & 11 is not zero, I would want to keep both of those entries. Rondeondo's solution is close. I do like using the filter option but couldn't get it to work either. Your statement about numbers repeating can happen so I don't think the "Unique" option would work.



current_discrepancies_202308120305.xlsx
ABC
1LocationModelVariance
2111126
32111-26
4322218
5422215
65222-18
7633360
87444345
98444-345
10955550
111066667
121166667
Sheet1
 
Upvote 0
I came up with this formula ; IF(SUMIFS($C$2:$C$21,$B$2:$B$21,B2)=0,"Remove",""). Again, this is close to working but not quite. It doesn't calculate Locations 3 & 5 correctly. Those should be removed but it doesn't catch them I think because there are three occurrences of model # "222". Even though the 18s cancelling each other out, the 15 is higher than zero so it doesn't flag it. I am not sure how to get around this or if someone has a better solution. Thanks in advance.
 
Upvote 0
Hello again,

I am not sure if I should start a new post but I am sure someone will tell me.

I was able to get the correct results if there are two duplicate model numbers
If there are more than two model numbers, this is where I am stuck.

Column E has the correct results.
Column F is where I started creating a formula but could not get it to work. How do you compare combinations of individual entries of the same model number?
For model # 777, there are 6 occurrences. The (location 12) -950.40 and (Location 15) 950.40 =0 so that should be removed.
The (location 13) 475.20 + (location 17) 2376=2851.20. So either location 14 or location 16 with -2851.20 can be removed.

Any help/advice is appreciated.

current_discrepancies_202308120305.xlsx
ABCDEF
1LocationModelVarianceIf ony 2 dup Model# (This is working)If more than 2 Model# Desired ResultsNot working
2111126Remove 
32111-26Remove 
4322218 Remove15
5422215 15
65222-18 Remove15
7633360  
87444345Remove 
98444-345Remove 
10955550  
111066667  
121166667  
1312777-950.4 Remove-2851.2
1413777475.2 Remove-2851.2
1514777-2851.2 Remove-2851.2
1615777950.4 Remove-2851.2
1716777-2851.2 -2851.2
18177772376 Remove-2851.2
Sheet1
Cell Formulas
RangeFormula
D2:D18D2=IF(COUNTIF($B$2:$B$18,B2)=2,IF(SUMIFS($C$2:$C$18,$B$2:$B$18,B2)=0,"Remove",""),"")
F2:F18F2=IF(COUNTIF($B$2:$B$18,B2)>2,SUMIF($B$2:$B$18,B2,$C$2:$C$18),"")
 
Upvote 0
I came up with a different approach since I couldnt get what I originally wanted through VBA.
 
Upvote 0

Forum statistics

Threads
1,215,101
Messages
6,123,092
Members
449,095
Latest member
gwguy

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