【问题标题】:How to add documentation to custom functions in Power Query Custom Connector?如何将文档添加到 Power Query 自定义连接器中的自定义函数?
【发布时间】:2019-12-10 15:00:35
【问题描述】:

我正在为 Power BI 构建一个自定义连接器,并且我想将文档添加到我的自定义函数中。我已经阅读了官方文档和一些关于此的博客文章。我看不出有什么问题。 我尝试过的:

section CustomConnector;

// this the function that gets exposed to the UI
[DataSource.Kind="CustomConnector", Publish="CustomConnector.Publish"]
shared CustomConnector.Contents = () =>
    let
        source = Navigation()
    in
        source;

// This is my navigator
Navigation = () =>
    let
      objects = #table(
       {"Name",                "Key",                   "Data",                                                             "ItemKind", "ItemName", "IsLeaf"},{    
       {"Function1",         "GetFunction1",     GetFunction1(),                                                "Table",    "Table",     true}, 
       {"Function2",  "CustomConnector.Function2", (optional artist_id as text) as table => CustomConnector.Function2(artist_id), "Function", "Function",  true}}),
        NavTable = Table.ToNavigationTable(objects, {"Key"}, "Name", "Data", "ItemKind", "ItemName", "IsLeaf") 
    in
        NavTable;

// This is an example of the function I want to provide documentation for
GetFunction2 = (optional artist_id) =>   
    let 
       source = "https://www.example.com/",
       response = Json.Document( Web.Contents ( source, [RelativePath = path & artist_id]) )
    in
       response;

// now the custom type function
GetFunction2Type = type function 
        (             
            optional artist_id as text  
        ) as table meta 
            [
                Documentation.Name = "GetFunction2",
                Documentation.LongDescription = "This function returns a table with details about the artist.",
                Documentation.Examples = 
                {
                    [
                        Description = "This function returns a table with details about the artist.",
                        Code = "GetFunction2(6WCWkB4bsGX2HDsoyaQb6KyL)",
                        Result = "Source = #table(
                                                {
                                                  ""something"",   
                                                  ""something2""   
                                                }, {{},{})"
                    ]
                }
            ];

// This is where I replace the original type for the custom type.
[DataSource.Kind = "CustomConnector"]
shared CustomConnector.GetFunction2 = Value.ReplaceType(GetFunction2 , GetFunction2Type);

// and here is my DataSource.Kind record
CustomConnector = [

    TestConnection = (dataSourcePath) => { "CustomConnector.Navigation" },
    Authentication = [
        OAuth = [
            StartLogin = StartLogin,
            FinishLogin = FinishLogin,
            Refresh = Refresh,
            Logout = Logout
        ]
    ]
];

文档中的重要方面:“与数据源关联的函数必须具有相同的必需函数参数(包括名称、类型和顺序)。特定数据源种类的函数只能使用与该种类关联的凭据。”。 我想我明白这一点。 现在这是 Power BI 导航器上的显示方式:

这与我实现自定义文档功能之前相同。什么也没发生,它工作正常。

谁能发现我犯的一些错误? 谢谢。

【问题讨论】:

    标签: powerbi powerquery m


    【解决方案1】:

    This 文章描述了同时反映函数和参数文档的问题。 cmets中有一个链接表明这是一个平台错误。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-01-25
      • 1970-01-01
      • 2017-01-12
      • 2022-01-23
      • 2012-07-18
      • 1970-01-01
      • 1970-01-01
      • 2021-10-26
      相关资源
      最近更新 更多