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
Thanks for your help here MFelix. I already am leveraging a function (Base Code - New), and am passing in 3 parameters to this. However my issue lies in that I have 20 sources for this function (differing Adobe Analytics report suites accessed via the API).
Currently what I am doing is running 20 queries, each with a different source.
What I would like to do is have 1 query, and loop through my function 20 times, each time adjusting my 'country' parameter (startDateNew and endDateNew remain the same). This would clean up my queries.
Currently the 20 queries create 20 tables and then I have used a little DAX to UNION them all together in a new table.
My ideal output would be a single table with all of the data appended. This would clean up my tables.
And again, thanks for the help here and apologizes for not being clearer before :)