Genre: Instruction

importHtml Syntax: ImportHtml(URL, query, index) URL is the URL of the HTML page. Either "list" or "table" indicates what type of structure to pull in from the webpage. If it's "list," the function looks for the contents of &lt;UL&gt;, &lt;OL&gt;, or &lt;DL&gt; tags; if it's "table," it just looks for &lt;TABLE&gt; tags. Index is the 1-based index of the table or the list on the source web page. The indices are maintained separately so there might be both a list #1 and a table #1. Using TRANSPOSE The answer is yes, you can TRANSPOSE a importHTML. Let use the Demographics of India table from the support documentation as an example. To switch columns into rows we can use =TRANSPOSE(ImportHtml("http://en.wikiped\\... "table";4)) This lets us change the way the data is imported from this: to this: Using QUERY Lets now say we are only interested in the population figures for 1991 and 2001.  You could always just import all the data then pull it using a cell reference. Another way of doing this is to wrap our data in a QUERY formula . data -- is an array of values (this can be a cell reference like data!B2:H6 or a imported range) query -- A query string for applying data operations. If you are using a cell reference or importRange then the 'query operates on column IDs directly from the input range and uses a subset of the SQL language. For example, "select E," "select A , B," "sum(B),C group by C," "select D where D &lt; 'Nick' ."' Note: When using importHTML column IDs are the column numbers using Col{number} e.g. "select Col1, Col2" eaders -- A number specifying the number of header rows in the input range. If omitted, or set to -1, the number of header rows is guessed from the input range. This parameter enables transformation of multi-header rows range input to be transformed to a single row header input which the QUERY supports. Anyone used to tinkering with databases will recognise the query language which uses the clauses like SELECT, WHERE, GROUP_BY etc. There are a couple of ways to query our data for the population of India in 1991 and 2001. Using LIMIT and OFFSET Limit -- Limits the number of returned rows. Offset -- Skips a given number of first rows. Using these we could use the query "SELECT * LIMIT 2 OFFSET 4" . This selects all the columns (using *) and then limits to 2 results starting from the 4th row. The order of limit/offset is important, using these the other way around won't return any results. SELECT columns Select -- Selects which columns to return, and in what order. If omitted, all of the table's columns are returned, in their default order. Because we are using importHTML as our datasource when selecting the columns we need to use the syntax Col1, Col2, Col3 .... So if you just want the year and population our query could be "SELECT Col1, Col2 LIMIT 2 OFFSET 4" WHERE rows Where -- Returns only rows that match a condition. If omitted, all rows are returned. One issue with using limit/offset is if more data is inserted into the source table it might push your results out of the range. A way around this is to include a WHERE clause to only include data on certain conditions. WHERE allows various comparison operators like &lt;=, =, &gt;, multiple conditions ('and', 'or' and 'not') and more complex string comparisons like 'contains'. More information on WHERE conditions here . So if we only wan the population where the year is 1991 or 2001 we can use the query "SELECT Col1, Col2 where Col1='*1991*' or Col1='*2001*'" For this last example lets also TRANSPOSE the result and remove the table header: