How to exclude certain data points

peterh2o

New Member
Joined
Jan 22, 2007
Messages
33
I'm running a query of 30 and 60 days worth of data but I don't want certain dates to be included in the queries. How do I exclude certain dates and at the same time pull in day 31 to include this in my 30 day high or average etc.? For example:

1/19/2007 4.7
1/18/2007 4.5
1/17/2007 3.8
1/16/2007 4.9
1/15/2007 3.75
1/12/2007 3.75

I want to exclude 1/15 because it is a holiday and it just repeats the data from 1/12. So I want it to pull in the data for 1/12 if I were doing a 5 day query. As I said before I need to do a MAX, MIN, AVERAGE and STDEV of 30 and 60 days but my formulas are skewed because of the holidays. Thanks!
 

Excel Facts

How can you automate Excel?
Press Alt+F11 from Windows Excel to open the Visual Basic for Applications (VBA) editor.
Assuming that A2:B7 contains the data, and G2:G10 contains a list of holidays, let D2 contain 5 (indicating a 5 day query), then try the following formula which needs to be confirmed with CONTROL+SHIFT+ENTER, not just ENTER...

=AVERAGE(IF(ROW($A$2:$A$7)<=SMALL(IF(ISNA(MATCH($A$2:$A$7,$G$2:$G$10,0)),ROW($A$2:$A$7)),D2),IF(ISNA(MATCH($A$2:$A$7,$G$2:$G$10,0)),$B$2:$B$7)))

Adjust the ranges accordingly, and amend the list of holidays and its reference, as needed. Replace AVERAGE with MAX, MIN, and STDEV...

Hope this helps!
 
Upvote 0
Domenic-
Sorry but I should have mentioned that the dates and data are in two separate columns.

Yes, the solution offered is based on that understanding...
 
Upvote 0
Domenic-
Thanks so much for the help with this. I have one final question regarding this formula, is there a way so that it takes the 30 days from the top to bottom because it seems as though it's taking the 30 days from the bottom of my list. I hope this makes sense. Thanks again though!
 
Upvote 0
... is there a way so that it takes the 30 days from the top to bottom...

Actually, the formula does indeed work this way...
 
Upvote 0
I can't seem to get the formula to work correctly on my production sheet but on my beta sheet it works perfect. On my production sheet the data is being filled from references to other tabs. Could this be a problem because my beta sheet is all text that I input to test the formula?
 
Upvote 0
Assuming that you've confirmed the formula with CONTROL+SHIFT+ENTER, make sure that the dates are being recognized as true date values. What does the following return?

=ISNUMBER(A2)

...where A2 contains a date within your date column.
 
Upvote 0
Domenic-
I have confirmed the formula with ctrl+shift+enter. The dates are showing up as FALSE while the data points are coming up as TRUE.
 
Upvote 0

Forum statistics

Threads
1,214,429
Messages
6,119,435
Members
448,898
Latest member
dukenia71

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