look up the closest numeric value above, and undertake "x"

eejwo

New Member
Joined
Nov 29, 2018
Messages
12
Office Version
  1. 365
Platform
  1. Windows
I am trying to undertake some crude data filtering. I have a single column of data, which requires filtering based on three rules:

1) if the current value is numeric and equal to the previous numeric value, replace with #N/A, otherwise keep current numeric value.
2) if the current value is numeric and greater or less than 0.5 difference from the previous numeric value, replace with #N/A, otherwise keep current numeric value.
3) if the previous value is #N/A or non-numeric, look up the closest previous numeric value above, and undertake 1) and 2).

Obviously 1) and 2) are very easy to achieve, but I'm struggling with 3). Any ideas for a solution (formula or VBA)? Thanks in advance.

Example raw data and the desired filtered result for illustrative purposes:

Book1
AB
1rawfiltered
20.5
311
41.51.5
522
62.52.5
72.5#N/A
83.1#N/A
93.2#N/A
103.3#N/A
112.62.6
Sheet1
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Perhaps this formula in B8 and copied to the other cells in the column would work for you.
=IF(ABS(LOOKUP(99e+99,B$1:B7)-A8)<.5,"N/A",A8)
 
Last edited:
Upvote 0
=IF(ABS(LOOKUP(99e+99,B$1:B7)-A8)<.5,"N/A",A8)

Hi Mik,

Have just tried your suggested formula in cell B8 and copied to others and this doesn't solve the problem. This produces all values as #N/A.

Should note also - whilst the snippet I provided above is just ten rows of data, I need it to work for n number of rows.
 
Upvote 0
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

As well as the above can you provide the expected results for this sample, particularly in relation to rule 3.
As I understand it cell B3 would be #N/A (rule 1) so when you get to B4, how do you "look up the closest previous numeric value above," when there are no numbers (directly) above?

Is it correct that B2 would always be blank or should/could it contain the A2 value?

21 06 19.xlsm
AB
1rawfiltered
21.2
31.2
41.5
52
62.5
72.5
83.1
93.2
103.3
112.6
Sample
 
Upvote 0
Thanks for making me aware, I've updated my account details.

The example sample you have provided would indeed break the filtering, i.e. as you suggested, because cell B3 would be #N/A, B4 will have no numeric value to lookup. So yes, if we can add the assumption that B2 = A2, rather than blank, that should work.

I've completed your sample below with this extra assumption, I hope this adds clarity.

Book2
AB
1rawfiltered
21.21.2
31.2#N/A
41.51.5
522
62.52.5
72.5#N/A
83.1#N/A
93.2#N/A
103.3#N/A
112.62.6
Sheet1
 
Upvote 0
Great, that does the trick, thanks!

Being pernickety, is it possible to build the clause for cell B2 into the formula that is applied thereafter, so that the one formula can be copied down for the whole column? (I'm working with an excel add-in which extracts data from a database. When setting up templates, for calculated data columns, I just apply the formula to the first two rows in the template. When querying the database it then copies the formula down in the calculated column alongside the n number of rows of data from the database).
 
Upvote 0
Great, that does the trick, thanks!

Being pernickety, is it possible to build the clause for cell B2 into the formula that is applied thereafter, so that the one formula can be copied down for the whole column? (I'm working with an excel add-in which extracts data from a database. When setting up templates, for calculated data columns, I just apply the formula to the first two rows in the template. When querying the database it then copies the formula down in the calculated column alongside the n number of rows of data from the database).
Ignore me, incorporated with "ROW" no problem.
 
Upvote 0
You're welcome. Glad you got the last bit sorted out. (y)
 
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,687
Members
449,117
Latest member
Aaagu

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