PowerBi 使用聚合 odata 源(或指定 type=open 进行 odata 查询)

问题描述 投票:0回答:1

我正在尝试将 Azure DevOps Analytics 中的聚合 odata 查询添加到 PowerBi,该查询(独立运行)如下所示。这将返回测试执行进度的每日快照。

https://analytics.dev.azure.com/{orgId}/{ProjectId}/_odata/v4.0-preview/TestPointHistorySnapshot?
$apply=
     filter(DateSK ge 20240301 and TestPlanId eq {PlanId})
     /groupby((DateSK,ResultOutcome),
      aggregate($count as TotalCount)
      )

这结合起来

https://analytics.dev.azure.com/ORG/PROJECT/_odata/v4.0-preview/TestPointHistorySnapshot?%24apply=filter%28DateSK+ge+20240301+and+TestPlanId+eq+PLANID%29+%2Fgroupby%28%28DateSK%2CResultOutcome%29%2C+aggregate%28%24count+as+TotalCount%29+%29

PowerBi 成功执行扁平化 URL,但拒绝解析响应并显示错误消息:

OData: The property 'TotalCount' does not exist on type 
'Microsoft.VisualStudio.Services.Analytics.Model.TestPointHistorySnapshot'. Make sure to only use
property names that are defined by the type or mark the type as open type.

选择

include open type columns
选项没有任何区别。我是否可以通过查询将类型指定为打开?

azure-devops powerbi odata
1个回答
0
投票

我找到了一种使用网络数据源类型来做到这一点的方法;它为数据源生成以下代码

let
    Source = Json.Document(Web.Contents("https://analytics.dev.azure.com/ORG/PROJECT/_odata/v4.0-preview/TestPointHistorySnapshot?%24apply=filter%28DateSK+ge+20240101+and+TestSuite%2FTestPlanId+eq+00000%29+%2Fgroupby%28+%28DateSK%29%2C+aggregate%28+%24count+as+TotalCount%2C+cast%28ResultOutcome++eq+%27Passed%27%2C+Edm.Int32%29+with+sum+as+Passed%2C+cast%28ResultOutcome++eq+%27Failed%27%2C+Edm.Int32%29+with+sum+as+Failed%2C+cast%28ResultOutcome+eq+%27Blocked%27%2C+Edm.Int32%29+with+sum+as+Blocked%2C+cast%28ResultOutcome+eq+%27NotApplicable%27%2C+Edm.Int32%29+with+sum+as+NotApplicable%2C+cast%28ResultOutcome+eq+%27None%27%2C+Edm.Int32%29+with+sum+as+NotExecuted%2C+cast%28ResultOutcome+ne+%27None%27%2C+Edm.Int32%29+with+sum+as+Executed+%29+%29")),
    #"Converted to Table" = Table.FromRecords({Source}),
    #"Expanded value" = Table.ExpandListColumn(#"Converted to Table", "value"),
    #"Expanded value1" = Table.ExpandRecordColumn(#"Expanded value", "value", { "DateSK", "Executed", "NotExecuted", "NotApplicable", "Blocked", "Failed", "Passed", "TotalCount"}, { "value.DateSK", "value.Executed", "value.NotExecuted", "value.NotApplicable", "value.Blocked", "value.Failed", "value.Passed", "value.TotalCount"}),
    #"Changed Type" = Table.TransformColumnTypes(#"Expanded value1",{ {"value.DateSK", Int64.Type}, {"value.Executed", Int64.Type}, {"value.NotExecuted", Int64.Type}, {"value.NotApplicable", Int64.Type}, {"value.Blocked", Int64.Type}, {"value.Failed", Int64.Type}, {"value.Passed", Int64.Type}, {"value.TotalCount", Int64.Type}})
in
    #"Changed Type"
© www.soinside.com 2019 - 2024. All rights reserved.