Solved

Query table in excel, filter by date

Posted on 2014-01-18
7
1,144 Views
Last Modified: 2014-01-21
I have a table of projects in Excel.  There is a column for Project Name and and column for End Date.  I would like a query in a separate worksheet that returns a column of data containing only those Project Names that end prior to a date I enter into a cell in Excel.  Suggestions for best way?

So far:
Pivot Table - does not have filter for less than arbitrary date.

Control Array - returns only filtered projects but leaves blank lines where projects do not match criteria.  I do not want blank lines.

VBA code - yes, I could build my own filter easily enough, but prefer existing tools if possible.  This may end up as best solution.

query builder - not friendly to finding tables in existing workbook.  I would like to be proven wrong about this.
0
Comment
Question by:RolandGarton
7 Comments
 
LVL 29

Expert Comment

by:gowflow
ID: 39790927
I could help in VBA if and when you feel ready have a file posted first.
gowflow
0
 
LVL 16

Accepted Solution

by:
Jerry Paladino earned 175 total points
ID: 39792097
If your data is in a List / Table format then MS-Query is a simple solution.   In Excel 2007-2013 - Data menu, Get External Data, From Other Sources, "From Microsoft Query".   This uses ODBC to make a connection to the Excel files.   In the Choose Data Source dialog, select Excel Files*.   Select the workbook in the next dialog and then select the Worksheet in the "Add Tables" dialog.   There is an "Options..." button on the Add Tables dialog.  Make sure "System Tables" is checked or the available worksheets in the workbook will not display.

Use the ADD button to select one or more worksheets.   From there you have the ability to join tables and write SQL.   The user interface provides some drag and drop but don't expect MS-Access like capabilities.  

Screen shots below and the attached PDF show the steps to build a query and add the Parameter for selecting the date to show your projects.   The PDF is for a query to MS-Access but the steps are the same and the document is more detailed than the screenshots below.

HTH
Jerry
Project ListChoose data sourceSelect WorkbookAdd TablesQuery GridProperties dialogPropertiesParametersResult SetParameter-Query-with-Excel.pdf
0
 
LVL 32

Assisted Solution

by:Rob Henson
Rob Henson earned 25 total points
ID: 39796888
Have you looked at the Advanced Filter function?

This can extract data for specific columns that match specific criteria. This can be on a separate worksheet in the same workbook or can filter the data in place.

Thanks
Rob H
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Author Closing Comment

by:RolandGarton
ID: 39797235
Jerry - very helpful, thanks much.  I appreciate the examples.  I'm glad to know about the parametric option for queries--will be useful in other applications.  Problem, though: Once I created a new query, I then wanted to edit the query.  When I right-click/Table/Edit query I get the "connecting to data source..." box I'm used to, but this box does not eventually yield to Microsoft Query.  Instead, it hangs Excel and I have to use Task Manager to exit.  Do you know how I can edit the query after I've set it up?

Rob H - Thanks for the pointer.  Advanced Filter with copy elsewhere is an option I didn't know about.  It's a one-time deal that doesn't automatically update, so not as robust as Jerry's solution.
0
 
LVL 16

Expert Comment

by:Jerry Paladino
ID: 39798850
Roland,

Go to "Connection Properties" dialog box, which is the screen shot third from the bottom that I posted above.   To the left of the Parameters button is the Edit Query button.   That will take you back to the MS-Query screens.  Once you are comfortable with the SQL syntax you can edit the SQL that you see in the "Command Text" box on that same dialog if you want to.   Or, continue to use the drag and drop capabilities within MS-Query.

Use the "Refresh" dropdown on the Data Ribbon to get to the Connection Properties dialog box as shown below:Connection Properties
0
 

Author Comment

by:RolandGarton
ID: 39798965
Same problem.  I get the Connecting to data source dialog, and Excel hangs, to be stopped only through the Task Manager.

Connecting message
0
 
LVL 16

Expert Comment

by:Jerry Paladino
ID: 39798992
Roland,

Not sure since it works fine on both of my laptops.  May I suggest that you use two separate files as a place to start troubleshooting.   Have your complete list of projects in one workbook and setup the Query in second workbook.   That may avoid the connection issues you are experiencing.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Drop Down List with Unique/Distinct Values (Part II - ComboBox or ListBox and Data Validation List Bonus!) David Miller (dlmille) Intro This article focuses on delivering unique, sorted lists to list objects (e.g., ComboBox, ListBox) and Dat…
Introduction While answering a recent question (http:/Q_27311462.html), I created an alternative function to the Excel Concatenate() function that you might find useful.  I tested several solutions and share the results in this article as well as t…
The viewer will learn how to simulate a series of coin tosses with the rand() function and learn how to make these “tosses” depend on a predetermined probability. Flipping Coins in Excel: Enter =RAND() into cell A2: Recalculate the random variable…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

948 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now