如果您将 .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 模型本身中度量)的唯一方法。