powerbi - Power BI 在列上使用 $expand
问题描述
Power BI新手在这里。
我想根据我的 Azure DevOps 数据(https://docs.microsoft.com/en-us/azure/devops/report/powerbi/sample-test-plans-execution )构建 Power BI 可视化,如示例报告中所示-trend?view=azure-devops&tabs=powerbi)。
使用 DateSK 制作 X 轴似乎不起作用,因为 PowerBI 将其视为一个整数,并且我的可视化中 X 轴的方式是线性的(绘制的 X 轴如下所示:20200100 20200150 20200200 20200250 等等)。我想查看 Microsoft 文档中显示的每日视图。
PowerBI 也不允许我将 DateSK 数据类型从整数转换为日期格式。
我曾尝试$expand
在我的 Power BI 查询中使用,但似乎日期列无法让我扩展或者我做错了。
如果您有任何解决方法或使用$expand
. 我想查看扩展的日期格式而不是 DateSK。
下面是来自微软文档的参考,如上面的链接所示:
let
Source = OData.Feed ("https://analytics.dev.azure.com/{organization}/{project}/_odata/v3.0-preview/TestPointHistorySnapshot?"
&"$apply=filter((TestSuite/TestPlanTitle eq '{testPlanTitle}') and (DateSK ge {startDate} and DateSK le {endDate}))"
&"/groupby("
&"(DateSK),"
&"aggregate("
&"$count as TotalCount,"
&"cast(ResultOutcome eq 'Passed', Edm.Int32) with sum as Passed,"
&"cast(ResultOutcome eq 'Failed', Edm.Int32) with sum as Failed,"
&"cast(ResultOutcome eq 'Blocked', Edm.Int32) with sum as Blocked,"
&"cast(ResultOutcome eq 'NotApplicable', Edm.Int32) with sum as NotApplicable,"
&"cast(ResultOutcome eq 'None', Edm.Int32) with sum as NotExecuted,"
&"cast(ResultOutcome ne 'None', Edm.Int32) with sum as Executed
)
)", null, [Implementation="2.0"])
in
Source
解决方案
我通过将列转换两次来实现这一点,首先是文本,然后是日期。
下面我展示了高级编辑器中的查询更改,但我在可视查询编辑器中进行了列转换。我在第一步将计数转换为整数,并将 dateSK 转换为文本。
在第二步中,我将 Date 列转换为日期,然后将该列从 DateSK 重命名为 Date。
#"Changed Type" = Table.TransformColumnTypes(Source,{{"TotalCount", Int64.Type}, {"Passed", Int64.Type}, {"Failed", Int64.Type}, {"Blocked", Int64.Type}, {"NotApplicable", Int64.Type}, {"NotExecuted", Int64.Type}, {"Executed", Int64.Type}, {"DateSK", type text}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Changed Type",{{"DateSK", type date}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"DateSK", "Date"}}),
推荐阅读
- javascript - Javascript 不执行
- php - 从数组php中删除键和值
- xml - 压缩的 XML 文件在 BBEdit 中显示正常,但在 Sublime Text 中不显示
- javascript - PM2 Digital Ocean Server 无法连接
- ansible-awx - 从 AWX 1.0.6 升级到 1.0.7
- apache-camel - Camel json-validator 抛出 Stream closed 异常
- docker - Docker 容器在挂载中收到权限被拒绝
- meteor - 用于传递变量的 GraphQL 查询参数语法
- debugging - fmt.Scanln 的调试问题
- python - Boto 出口安全策略