<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
     xmlns:admin="http://webns.net/mvcb/"
     xmlns:content="http://purl.org/rss/1.0/modules/content/"
     xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
	<channel> 

	<title>Comments on: How to run a query in Excel 2007?</title>
	<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007/</link>
	<description>Comments on Ask MetaFilter post How to run a query in Excel 2007?</description>
	<pubDate>Fri, 25 Jan 2008 08:24:59 -0800</pubDate>
	<lastBuildDate>Fri, 25 Jan 2008 08:24:59 -0800</lastBuildDate>
	<language>en-us</language>
	<docs>http://blogs.law.harvard.edu/tech/rss</docs>
	<ttl>60</ttl>

	<item>
		<title>Question: How to run a query in Excel 2007?</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007</link>	
		<description>How do I group values by a variable in Excel 2007? Essentially, I want to run a query. &lt;br /&gt;&lt;br /&gt; I have a table with columns like city, state, population, average income, average house price. This table is constantly being updated and amended, with the new info tacked on at the end. So for example, I might have &lt;small&gt;(all numbers completely pulled out of my ass)&lt;/small&gt;:&lt;br&gt;
&lt;br&gt;
Milwaukee, WI, 600000, 40000, 150000&lt;br&gt;
Bozeman, MT, 30000, 25000, 100000&lt;br&gt;
Chicago, IL, 2000000, 60000, 200000&lt;br&gt;
Madison, WI, 100000, 50000, 125000&lt;br&gt;
Springfield, IL, 100000, 40000, 100000&lt;br&gt;
&lt;br&gt;
I need to group the cities by state and calculate stuff like total population, average income and house price by state. So I want to end up with &lt;br&gt;
&lt;br&gt;
WI, 700000, 45000, 137500&lt;br&gt;
IL, 2100000, 50000, 150000&lt;br&gt;
&lt;br&gt;
I&apos;m familiar with Access but I can&apos;t use that for this project because the end user only has access to Excel (2007). I understand SQL (mostly), but I don&apos;t know if it can be used in Excel and if it can, I don&apos;t know where to put it. I don&apos;t know any other code well enough. Please, if you have some magic line of code that will work, tell me exactly where to put it, because I won&apos;t know.</description>
		<guid isPermaLink="false">post:ask.metafilter.com,2008:site.81932</guid>
		<pubDate>Fri, 25 Jan 2008 08:20:39 -0800</pubDate>
		<dc:creator>desjardins</dc:creator>
		
			<category>excel</category>
		
			<category>query</category>
		
			<category>lookup</category>
		
			<category>access</category>
		
	</item> <item>
		<title>By: birdherder</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1213639</link>	
		<description>can&apos;t you get summaries like that in a pivot table?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1213639</guid>
		<pubDate>Fri, 25 Jan 2008 08:24:59 -0800</pubDate>
		<dc:creator>birdherder</dc:creator>
	</item><item>
		<title>By: salvia</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1213647</link>	
		<description>(Don&apos;t know if this is for Excel 2007 or earlier versions);&lt;br&gt;
Data -&amp;gt; Filter -&amp;gt; AutoFilter.&lt;br&gt;
Drop down arrows appear above the titles of columns.&lt;br&gt;
Select the one for WI.&lt;br&gt;
&lt;br&gt;
Will this work with the way your data is set up?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1213647</guid>
		<pubDate>Fri, 25 Jan 2008 08:30:03 -0800</pubDate>
		<dc:creator>salvia</dc:creator>
	</item><item>
		<title>By: salvia</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1213667</link>	
		<description>Then to perform a particular operation (average this, add up that) on only the filtered rows, use one of the SUBTOTAL functions. Put it at the bottom of all the entries, but after you&apos;ve set up the Autofilter. &lt;a href=&quot;http://www.ozgrid.com/Excel/excel-subtotal-function.htm&quot;&gt;Details&lt;/a&gt;: &lt;blockquote&gt;The SUBTOTAL Function in Excel is used to perform a specified function on a range of Auto filtered cells. When the Auto Filter has been applied the SUBTOTAL function will only use the visible cells, all hidden rows are ignored. The operation performed is solely dependent on the number (between 1 and 11) that we supply to it&apos;s first argument Function_num For example;&lt;br&gt;
&lt;br&gt;
=SUBTOTAL(1,A1:A100)&lt;br&gt;
&lt;br&gt;
will Average all visible cell in the range A1:A100 after an Auto Filter has been applied. If all rows in A1:A100 are visible it will simply Average them all and give the same result as&lt;br&gt;
&lt;br&gt;
=AVERAGE(A1:A100)&lt;br&gt;
&lt;br&gt;
The number for the first SUBTOTAL argument, Function_num, and it&apos;s corresponding function are as shown below&lt;br&gt;
&lt;br&gt;
Function_Num&lt;br&gt;
&lt;blockquote&gt;Function&lt;br&gt;
1 	AVERAGE&lt;br&gt;
2 	COUNT&lt;br&gt;
3 	COUNTA&lt;br&gt;
4 	MAX&lt;br&gt;
5 	MIN&lt;br&gt;
6 	PRODUCT&lt;br&gt;
7 	STDEV&lt;br&gt;
8 	STDEVP&lt;br&gt;
9 	SUM&lt;br&gt;
10 	VAR&lt;br&gt;
11 	VARP&lt;/blockquote&gt;&lt;/blockquote&gt;The only annoying part is having to copy/paste-special--&amp;gt;values only the equation results into another table so they don&apos;t disappear when you filter for another variable.&lt;br&gt;
&lt;br&gt;
But yeah, depending on exactly what you want to end up with, I&apos;d probably try the pivot table first, like birdherder suggested.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1213667</guid>
		<pubDate>Fri, 25 Jan 2008 08:39:46 -0800</pubDate>
		<dc:creator>salvia</dc:creator>
	</item><item>
		<title>By: desjardins</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1213691</link>	
		<description>Thanks guys! Will a pivot table pick up new data that is entered or will I have to redo it?</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1213691</guid>
		<pubDate>Fri, 25 Jan 2008 08:52:49 -0800</pubDate>
		<dc:creator>desjardins</dc:creator>
	</item><item>
		<title>By: Pants!</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1213709</link>	
		<description>A pivot table is for a specific range, and the bigger the range, the bigger the file size.  But you could make a pivot table for entire columns by highlighting the column headings (A-E).&lt;br&gt;
&lt;br&gt;
The pivot table won&apos;t refresh automatically when new data is added, but you can right click on it and choose refresh.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1213709</guid>
		<pubDate>Fri, 25 Jan 2008 09:01:43 -0800</pubDate>
		<dc:creator>Pants!</dc:creator>
	</item><item>
		<title>By: entropone</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1213751</link>	
		<description>I would use VLOOKUP.&lt;br&gt;
&lt;br&gt;
VLOOKUP finds a variable in a datasheet, reads the column you specify, and reads it into the cell where the formula is.&lt;br&gt;
&lt;br&gt;
it&apos;s hard to explain but easy to do. let me know if you want more information.</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1213751</guid>
		<pubDate>Fri, 25 Jan 2008 09:43:02 -0800</pubDate>
		<dc:creator>entropone</dc:creator>
	</item><item>
		<title>By: salvia</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1213860</link>	
		<description>Yeah, you should be able to update a pivot table if you change values (I think you can right-click on the pivot table to see that option). I&apos;m not sure what will happen if you add entire rows, though. When you create the pivot table it asks what the data range is (default being the whole thing). So, if it gets set to A1 : Z99 and then you add a new row at line 8, the data range might automatically switch to A1:Z7, A9:Z100. &lt;br&gt;
&lt;br&gt;
The other issue with the pivot table is that to have multiple summary functions going on, you might end up having to create a dozen pivot tables.&lt;br&gt;
&lt;br&gt;
Another option you might look into would be to do something with grouping and &lt;a href=&quot;http://office.microsoft.com/en-us/excel/HA011097981033.aspx&quot;&gt;summary rows&lt;/a&gt;. &quot;First sort the products by category, [ie state], and then select all the cells that contain data and open the Subtotal dialog box (Data menu, Subtotals command)...&quot;</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1213860</guid>
		<pubDate>Fri, 25 Jan 2008 10:58:46 -0800</pubDate>
		<dc:creator>salvia</dc:creator>
	</item><item>
		<title>By: pompomtom</title>
		<link>http://ask.metafilter.com/81932/How-to-run-a-query-in-Excel-2007#1214118</link>	
		<description>For your groupings, the function you want is SUMIF.&lt;br&gt;
&lt;br&gt;
For the  example data you&apos;ve given, presuming we&apos;re starting in A1, you&apos;d have something like:&lt;br&gt;
&lt;br&gt;
=SUMIF(B:B,&quot;WI&quot;,C:C)&lt;br&gt;
&lt;br&gt;
...which is saying sum the values on column C if column B matches &quot;WI&quot;.&lt;br&gt;
&lt;br&gt;
To do averages, you&apos;d also use COUNTIF, so it&apos;d be, say:&lt;br&gt;
&lt;br&gt;
=SUMIF(B:B,&quot;WI&quot;,D:D)/COUNTIF(B:B,&quot;WI&quot;)</description>
		<guid isPermaLink="false">comment:ask.metafilter.com,2008:site.81932-1214118</guid>
		<pubDate>Fri, 25 Jan 2008 13:48:11 -0800</pubDate>
		<dc:creator>pompomtom</dc:creator>
	</item>
	</channel>
</rss>
