com
From here, we can filter and shape the data as we want it. Once
were happy with the way it looks, we will convert it to a function.
For the sake of the demo, Ive kept the query simple Im just
accessing the data, and Ive removed the Changed Type step
that Power Query automatically inserted for me. The only shaping I
did was to remove the bottom 3 summary rows on the page. My
code now looks this:
let
Source = Web.Page(Web.Contents("http://boxofficemojo.com
/yearly/chart/?page=1&view=releasedate&view2=domestic&
yr=2013&p=.htm")),
Data1 = Source{1}[Data],
RemoveBottom = Table.RemoveLastN(Data1,3)
in
RemoveBottom
Note that the url value in the call to Web.Contents contains a
query parameter (page) that specifies the page of data we want to
access.
To turn this query into a parameterized function, well add the
following line before the let statement.
(page as number) as table =>
The two as statements specify the expected data types for the
page parameter (number) and the return value of the function
(table). They are optional, but I like specifying types whenever I
can.
Weve now turned our query into a function, and have a parameter
You can click on the the Invoke button and enter a page value to
test it out.
Be sure to delete the Invoked Function step, then give the function
a meaningful name (like GetData). Once the function has been
given a good name, click Close & Load to save the query.
From the Power Query ribbon, select From Other Sources >
Blank Query. This brings up an empty editor page. In the formula
bar, type the following formula:
= {1..7}
This gives us a list of numbers from 1 to 7.
let
Source = {1..7},
ToTable = Table.FromList(Source, Splitter.SplitByNothing(),