Help with excel filter formula

manekankit

Board Regular
Joined
Feb 1, 2019
Messages
72
Office Version
  1. 365
Platform
  1. Windows
Dear members, having below query with excel filter function.

Given below is data set, formula 1 and formula 2.

Having query with formula 2 given below.

I am not getting why result of formula 2 is including item with units sold =4 when my condition for filter is unit sold is >5. (formula 2 is also not including units sold =7 item).

I am using office 365 desktop version.

Thanks.

A
1 Employee
B
Units Sold
C
Average Price
2 Tom
4​
2.99​
3 Jack
3​
2.95​
4 Suzie
7​
2.75​
5 Rajesh
4​
2.64​
6 Kevin
4​
3.05​
7 Belinda
3​
2.52​
8 Sally
8​
3.18​
9 David
9​
2.52​
This is a data set range (a1 to c9)
Result of formula 1
Suzie
7​
2.75​
Sally
8​
3.18​
David
9​
2.52​
Formula 1

=FILTER(SORTBY(A2:C9,B2:B9,1),SORTBY(B2:B9,B2:B9,1)>5)
This formula is giving correct result providing list where unit sold quantity is >5
Result of formula 2
Tom
4​
2.99​
Sally
8​
3.18​
David
9​
2.52​
Formula 2
=FILTER(SORTBY(A2:C9,B2:B9,1),B2:B9>5)
The query is why this formula is including "Tom" when it has unit sold = 5 but filter condition is >5
 

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.
Try it like
Excel Formula:
=sort(FILTER(A2:C9,B2:B9>5),2)
 
Upvote 0
Solution
filter first, then sort.
MrExcelPlayground19.xlsx
ABCDEFGHI
1EmpUnitsPrice
2Tom42.99
3Jack32.95
4Suzie72.75
5Rajesh42.64
6Kevin43.05
7Belinda32.52
8Sally83.18
9David92.52
10
11sortby outputfilter output
12Tom42.99Jack32.95FALSE
13Sally83.18Belinda32.52FALSE
14David92.52Tom42.99TRUE
15Rajesh42.64FALSE
16Kevin43.05FALSE
17Suzie72.75FALSE
18Sally83.18TRUE
19David92.52TRUE
20try this:
21Suzie72.75
22Sally83.18
23David92.52
Sheet33
Cell Formulas
RangeFormula
A12:C14A12=FILTER(SORTBY(A2:C9,B2:B9,1),B2:B9>5)
E12:G19E12=SORTBY(A2:C9,B2:B9,1)
I12:I19I12=B2:B9>5
A21:C23A21=SORT(FILTER(A2:C9,B2:B9>5),2)
Dynamic array formulas.
 
Upvote 0
I am using office 365 desktop version.
Please update your Profile then, as Excel 2016 does not have the Filter function.

1692362120385.png
 
Upvote 0
Thanks @Fluff and @JamesCanale for replying. I am still not clear why my second formula is not giving desired output. Could you please explain what's wrong with the second formula? If we see, it is in a way similar to the first formula which is working as expected.
 
Upvote 0
Updated. Sorry for inconvenience.
No worries. It just helps let us know which version you are using, so we know which functions will and will not work for you (and we won't recommend a solution that you cannot use).
 
Upvote 0
In your 1st formula you are sorting the data & the criteria & then filtering.
In the 2nd you are sorting the data, but not the criteria, therefore they do not line up

In E2 is the result of the sort & the green lines are those that match your criteria, so that is what is returned.
Fluff.xlsm
ABCDEFG
1EmpUnitsPrice
2Tom42.99Jack32.95
3Jack32.95Belinda32.52
4Suzie72.75Tom42.99
5Rajesh42.64Rajesh42.64
6Kevin43.05Kevin43.05
7Belinda32.52Suzie72.75
8Sally83.18Sally83.18
9David92.52David92.52
Master
Cell Formulas
RangeFormula
E2:G9E2=SORTBY(A2:C9,B2:B9,1)
Dynamic array formulas.
 
Upvote 0
In your 1st formula you are sorting the data & the criteria & then filtering.
In the 2nd you are sorting the data, but not the criteria, therefore they do not line up

In E2 is the result of the sort & the green lines are those that match your criteria, so that is what is returned.
Fluff.xlsm
ABCDEFG
1EmpUnitsPrice
2Tom42.99Jack32.95
3Jack32.95Belinda32.52
4Suzie72.75Tom42.99
5Rajesh42.64Rajesh42.64
6Kevin43.05Kevin43.05
7Belinda32.52Suzie72.75
8Sally83.18Sally83.18
9David92.52David92.52
Master
Cell Formulas
RangeFormula
E2:G9E2=SORTBY(A2:C9,B2:B9,1)
Dynamic array formulas.
Thank you.
 
Upvote 0
th
filter first, then sort.
MrExcelPlayground19.xlsx
ABCDEFGHI
1EmpUnitsPrice
2Tom42.99
3Jack32.95
4Suzie72.75
5Rajesh42.64
6Kevin43.05
7Belinda32.52
8Sally83.18
9David92.52
10
11sortby outputfilter output
12Tom42.99Jack32.95FALSE
13Sally83.18Belinda32.52FALSE
14David92.52Tom42.99TRUE
15Rajesh42.64FALSE
16Kevin43.05FALSE
17Suzie72.75FALSE
18Sally83.18TRUE
19David92.52TRUE
20try this:
21Suzie72.75
22Sally83.18
23David92.52
Sheet33
Cell Formulas
RangeFormula
A12:C14A12=FILTER(SORTBY(A2:C9,B2:B9,1),B2:B9>5)
E12:G19E12=SORTBY(A2:C9,B2:B9,1)
I12:I19I12=B2:B9>5
A21:C23A21=SORT(FILTER(A2:C9,B2:B9>5),2)
Dynamic array formulas.
thank you. this also explains in a simplified way.
 
Upvote 0

Forum statistics

Threads
1,223,886
Messages
6,175,196
Members
452,616
Latest member
intern444

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