Forum Discussion
paulvans182
6 years agoHelper III
Rename Query from within Advanced Editor of Invoke Function
Good morning,
I wonder if someone can help me with this, or let me know if it is even possible.
I have 3 tables in 3 files with identical layouts. I am re-using my script for my first table to reload the other 2 tables by using a blank query and parameter to define the name of the other two files:
(status)=>
let
Source = Csv.Document(File.Contents("C:\Users\Paul\Documents\Power BI\Covid\data\time_series_covid19_" & status & "_global.csv"),[Delimiter=",", Encoding=1252, QuoteStyle=QuoteStyle.None]),
#"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]),
#"Removed Columns" = Table.RemoveColumns(#"Promoted Headers",{"Province/State", "Lat", "Long"}),
#"Unpivoted Other Columns" = Table.UnpivotOtherColumns(#"Removed Columns", {"Country/Region"}, "Attribute", "Value"),
#"Changed Type" = Table.TransformColumnTypes(#"Unpivoted Other Columns",{{"Attribute", type date}, {"Value", Int64.Type}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Attribute", "Date"}, {"Value", status}})
in
#"Renamed Columns"
This works perfectly.
However, when I trigger the query to load my new files, the tables are automatically named:
Invoked Function
Invoked Function (2)
Is it possible, from within the script, to rename a query? I realize I can just rename it manually, I am just interested if it is possible to do so.