Forum Discussion

paulvans182's avatar
paulvans182
Helper III
6 years ago

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.

3 Replies

  • mwegener's avatar
    mwegener
    Most Valuable Professional

    Hi paulvans182 ,

     

    try this.

    Import the folder and adapt the Transform File function accordingly.

     

  • Anonymous's avatar
    Anonymous
    Not applicable

    Did you solve this?

    I´m trying to find a way to name the tables created from a function or rename them after creation.

  • Hello, did you end up finding a way to have the Invoke Function be named from the advanced editor?