【问题标题】:Power BI using $expand on columnsPower BI 在列上使用 $expand
【发布时间】:2020-05-29 20:55:24
【问题描述】:

Power BI 新手在这里。

我想根据我的 Azure DevOps 数据 (https://docs.microsoft.com/en-us/azure/devops/report/powerbi/sample-test-plans-execution-trend?view=azure-devops&tabs=powerbi) 构建示例报告中所示的 Power BI 可视化。

使用 DateSK 制作 X 轴似乎不起作用,因为 PowerBI 将其视为一个整数,并且我的可视化中 X 轴的方式是线性的(绘制的 X 轴如下所示:20200100 20200150 20200200 20200250 等等上)。我想查看 Microsoft 文档中显示的每日视图。

PowerBI 也不允许我将 DateSK 数据类型从整数转换为日期格式。

我曾尝试在我的 Power BI 查询中使用 $expand,但似乎日期列无法让我扩展或者我做错了。

如果您有任何解决方法或使用$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

【问题讨论】:

    标签: powerbi odata


    【解决方案1】:

    我通过将该列转换两次来实现这一点,首先是文本,然后是日期。

    下面我显示了高级编辑器中的查询更改,但我在可视查询编辑器中进行了列转换。我在第一步中将计数转换为整数,并将 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"}}),
    

    【讨论】:

      猜你喜欢
      • 2018-06-21
      • 1970-01-01
      • 2020-04-27
      • 2018-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      相关资源
      最近更新 更多