【问题标题】:How can I retrieve the list of measures contained in a SSAS connected Power BI report?如何检索 SSAS 连接的 Power BI 报表中包含的度量列表?
【发布时间】:2020-03-29 20:03:27
【问题描述】:

我正在处理组织中其他人创建的 PBI 报告,我需要对报告本身包含的所有度量(50 或更多)进行一些审核。

报告连接到 SQL Server Analysis Services 的本地实例。

我正在尝试获取报告中包含的所有措施的列表。为了实现这一点,在以前的情况下,我使用 DAX Studio 连接到 PBI 桌面的运行实例,如 https://exceleratorbi.com.au/getting-started-dax-studio/ 中所述。

但是,由于此报表连接到 SSAS,当我尝试将 DAX Studio 连接到它时,我收到错误消息: “连接到 PBI 桌面时未找到数据库。如果您的 PBI 文件使用实时连接,请直接连接到源模型。”

我可以使用另一种已知方法从 PBIX 本身提取所有度量吗?

【问题讨论】:

  • 直接连接到 SSAS,如错误消息所示。
  • 如问题中所述,我的措施不在 SSAS 模型中,而是在 PBIX 文件中。

标签: powerbi dax


【解决方案1】:

如果您将 .pbix 文件重命名为 .zip 并将其作为 zip 文件打开,您将看到一个报告文件夹,然后是一个名为 Layout 的文件。如果您从 .zip 文件中复制该文件并在文本编辑器(最好是可以格式化 JSON 的应用程序)中打开它,您将看到以下内容:

{
  "id": 0,
  "resourcePackages": [
    //some packages here
  ],
  "sections": [
    //some sections here...
  ],
  "config": "{\"version\":\"5.3\",\"themeCollection\":{\"baseTheme\":{\"name\":\"CY19SU06\",\"version\":\"5.5\",\"type\":2}},\"activeSectionIndex\":0,\"modelExtensions\":[{\"name\":\"extension\",\"entities\":[{\"name\":\"DimDate\",\"extends\":\"DimDate\",\"measures\":[{\"name\":\"My Report Measure\",\"dataType\":3,\"expression\":\"DIVIDE(99,100)\",\"errorMessage\":null,\"hidden\":false,\"formulaOverride\":null,\"formatInformation\":{\"formatString\":\"G\",\"format\":\"General\",\"thousandSeparator\":false,\"currencyFormat\":null,\"dateTimeCustomFormat\":null}}]},{\"name\":\"DimCustomer\",\"extends\":\"DimCustomer\",\"measures\":[{\"name\":\"My Report Measure 2\",\"dataType\":3,\"expression\":\"99 + 100\",\"errorMessage\":null,\"hidden\":false,\"formulaOverride\":null,\"formatInformation\":{\"formatString\":\"G\",\"format\":\"General\",\"thousandSeparator\":false,\"currencyFormat\":null,\"dateTimeCustomFormat\":null}}]}]}],\"defaultDrillFilterOtherVisuals\":true,\"settings\":{\"useStylableVisualContainerHeader\":true,\"exportDataMode\":1,\"useNewFilterPaneExperience\":true,\"allowChangeFilterTypes\":true},\"objects\":{\"section\":[{\"properties\":{\"verticalAlignment\":{\"expr\":{\"Literal\":{\"Value\":\"'Top'\"}}}}}]}}",
  "layoutOptimization": 0
}

如果您查看 config 属性,就会发现其中包含 JSON 的字符串。如果您提取 JSON 并对其进行格式化,您将得到:

{
  "version": "5.3",
  "themeCollection": {
    "baseTheme": {
      "name": "CY19SU06",
      "version": "5.5",
      "type": 2
    }
  },
  "activeSectionIndex": 0,
  "modelExtensions": [
    {
      "name": "extension",
      "entities": [
        {
          "name": "DimDate",
          "extends": "DimDate",
          "measures": [
            {
              "name": "My Report Measure",
              "dataType": 3,
              "expression": "DIVIDE(99,100)",
              "errorMessage": null,
              "hidden": false,
              "formulaOverride": null,
              "formatInformation": {
                "formatString": "G",
                "format": "General",
                "thousandSeparator": false,
                "currencyFormat": null,
                "dateTimeCustomFormat": null
              }
            }
          ]
        },
        {
          "name": "DimCustomer",
          "extends": "DimCustomer",
          "measures": [
            {
              "name": "My Report Measure 2",
              "dataType": 3,
              "expression": "99 + 100",
              "errorMessage": null,
              "hidden": false,
              "formulaOverride": null,
              "formatInformation": {
                "formatString": "G",
                "format": "General",
                "thousandSeparator": false,
                "currencyFormat": null,
                "dateTimeCustomFormat": null
              }
            }
          ]
        }
      ]
    }
  ],
  "defaultDrillFilterOtherVisuals": true,
  "settings": {
    "useStylableVisualContainerHeader": true,
    "exportDataMode": 1,
    "useNewFilterPaneExperience": true,
    "allowChangeFilterTypes": true
  },
  "objects": { "section": [ { "properties": { "verticalAlignment": { "expr": { "Literal": { "Value": "'Top'" } } } } } ] }
}

您将在 DimDate 表中看到 My Report Measure,即表达式 DIVIDE(99,100),在 DimCustomer 表中看到 My Report Measure 2,即表达式 99 + 100。这些都是简单的例子,但它给了你想法。

显然,这都是无证的,可能会发生变化。但这是我知道的将这些度量添加到 PBIX(而不是在 SSAS 模型本身中度量)的唯一方法。

【讨论】:

  • 谢谢你,格雷格。我认为这种方法现在会有所帮助。希望将来有人能想出一个工具来一次性从 pbix 中提取所有度量值。
猜你喜欢
  • 2017-03-11
  • 2023-03-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-08-23
相关资源
最近更新 更多