Forum Discussion

JustSomeGuy's avatar
JustSomeGuy
New Member
1 year ago

Power Query SDK - Naming the Output Query

I created a custom connector for PowerBI using the Power Query SDK. When I run it in PowerBI the result is always "Query1" (for the frist one, Query2 for the second, etc.).

Is there any way I can set the naming schema of the query using the SDK?

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JustSomeGuy ,

    I checked the official documentation, but it seems that there is no way to set it. You might try to define the name yourself:

    let
        Query1 = YourQueryFunction1(),
        Query2 = YourQueryFunction2()
    in
        Record.FromList({Query1, Query2}, {"Query1", "Query2"})
    


    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

    • JustSomeGuy's avatar
      JustSomeGuy
      New Member

      Thank you for the suggestion, but I tried the code in the link and the outcome still says "Query1".

      • ZhangKun's avatar
        ZhangKun
        Icon for Super User rankSuper User

        Maybe your code is wrong, or I misunderstood your problem. Here are the code and screenshots.

         

        shared TestRename.Contents = (optional message as text) =>
        // START!!!!
        
        
            SampleTable();
        
        SampleTable = () => 
            let
                objects = #table(
                    {"Name", "Key", "Data", "ItemKind", "ItemName", "IsLeaf"},
                    {
                        {"JustSomeGuy", "item1", #table({"Column1"}, {{1}}), "Table", "Table", true},
                        {"Item2", "item2", #table({"Column1"}, {{2}}), "Table", "Table", true}
                    }
                ),
                NavTable = Table.ToNavigationTable(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf")
            in
                NavTable;
        Table.ToNavigationTable = (
            table as table,
            keyColumns as list,
            nameColumn as text,
            dataColumn as text,
            itemKindColumn as text,
            itemNameColumn as text,
            isLeafColumn as text
        ) as table =>
            let
                tableType = Value.Type(table),
                newTableType = Type.AddTableKey(tableType, keyColumns, true) meta [
                    NavigationTable.NameColumn = nameColumn,
                    NavigationTable.DataColumn = dataColumn,
                    NavigationTable.ItemKindColumn = itemKindColumn,
                    Preview.DelayColumn = itemNameColumn,
                    NavigationTable.IsLeafColumn = isLeafColumn
                ],
                navigationTable = Value.ReplaceType(table, newTableType)
            in
                navigationTable;
        
        
        // END!!!!!
        // Data Source Kind description

         

        After generating the extension and loading it into Power BI and clicking on it in the connector list:

        After clicking the OK button: