Forum Discussion
Create multiple tables from single query
- 8 years ago
Hi chriswragge,
As it is refered in the links I provided you can do a single query that is transformed in a function on that function you need to refer to a variable (identified as (something) => )
Then adding a table with all the variable you need to change alonside with the custom functions you will get a single querie and not 20.
See attach an example with a webpage change.
Custom Function
(page) => let Source = Web.Page(Web.Contents("https://editorial.rottentomatoes.com/guide/200-essential-movies-to-watch-now/" & Number.ToText(page) &"/")), Data0 = Source{0}[Data], #"Changed Type" = Table.TransformColumnTypes(Data0,{{"Column1", Percentage.Type}, {"Column2", type text}}) in #"Changed Type"Final Query
let Source = {2..5}, #"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error), #"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each WebPage([Column1])), #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Column1", "Column2"}, {"Custom.Column1", "Custom.Column2"}) in #"Expanded Custom"Regards,
MFelix
Hi chriswragge,
As it is refered in the links I provided you can do a single query that is transformed in a function on that function you need to refer to a variable (identified as (something) => )
Then adding a table with all the variable you need to change alonside with the custom functions you will get a single querie and not 20.
See attach an example with a webpage change.
Custom Function
(page) =>
let
Source = Web.Page(Web.Contents("https://editorial.rottentomatoes.com/guide/200-essential-movies-to-watch-now/" & Number.ToText(page) &"/")),
Data0 = Source{0}[Data],
#"Changed Type" = Table.TransformColumnTypes(Data0,{{"Column1", Percentage.Type}, {"Column2", type text}})
in
#"Changed Type"
Final Query
let
Source = {2..5},
#"Converted to Table" = Table.FromList(Source, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Added Custom" = Table.AddColumn(#"Converted to Table", "Custom", each WebPage([Column1])),
#"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Column1", "Column2"}, {"Custom.Column1", "Custom.Column2"})
in
#"Expanded Custom"Regards,
MFelix
This is so cool. This was exactly what I was looking for!! Thanks so much for all the help MFelix.