我过去创建了一个 .pbix 文件,以 Azure DocumentDB 作为源。现在属于 DocumentDB 的数据库名称已更改为包含破折号的名称(即 ebsaz-ddbesb-telemetry-o),这似乎导致 Power BI 编辑查询屏幕中高级编辑器下的 M 语法出现一些问题。
我认为应该有一种简单的方法来转义特殊字符(在这种情况下为破折号),例如单引号或双引号、方括号、常规括号等。我尝试了各种括号和引号,但似乎没有解决这个问题。这是M语言代码,感谢您的帮助:
let
Source = DocumentDB.Contents("https://ebsaz-ddbesb-301.documents.azure.com:443/"),
ebsaz-ddbesb-telemetry-o = Source{[id="ebsaz-ddbesb-telemetry-o"]}[Collections],
ebsaz-ddbesb-telemetry-o_ElectricityTelemetryData = ebsaz-ddbesb-telemetry-o{[db_id="ebsaz-ddbesb-telemetry-o",id="ElectricityTelemetryData"]}[Documents],
#"Expanded Document" = Table.ExpandRecordColumn(ebsaz-ddbesb-telemetry-o_ElectricityTelemetryData, "Document", {"dataAccessPointid", "eanCode", "electricityUsageLowkWh", "electricityUsageNormalkWh", "id", "dataSource", "timeStamp"}, {"Document.dataAccessPointid", "Document.eanCode", "Document.electricityUsageLowkWh", "Document.electricityUsageNormalkWh", "Document.id", "Document.dataSource", "Document.timeStamp"}),
#"Reordered Columns" = Table.ReorderColumns(#"Expanded Document",{"Document.id", "Document.dataAccessPointid", "Document.eanCode", "Document.ElectricityUsageLowkWh", "Document.ElectricityUsageNormalkWh", "Document.dataSource", "Document.timeStamp"}),
#"Changed Type" = Table.TransformColumnTypes(#"Reordered Columns",{{"Document.id", type text}}),
#"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Document.id", "GUID"}}),
#"Changed Type1" = Table.TransformColumnTypes(#"Renamed Columns",{{"Document.dataAccessPointid", Int64.Type}}),
#"Renamed Columns1" = Table.RenameColumns(#"Changed Type1",{{"Document.dataAccessPointid", "DATAACCESSPOINTID"}}),
#"Changed Type2" = Table.TransformColumnTypes(#"Renamed Columns1",{{"Document.eanCode", Int64.Type}}),
#"Renamed Columns2" = Table.RenameColumns(#"Changed Type2",{{"Document.eanCode", "EANCODE"}}),
#"Changed Type3" = Table.TransformColumnTypes(#"Renamed Columns2",{{"Document.ElectricityUsageLowkWh", type number}}),
#"Renamed Columns3" = Table.RenameColumns(#"Changed Type3",{{"Document.ElectricityUsageLowkWh", "ElectricityUsageLowkWh"}}),
#"Changed Type4" = Table.TransformColumnTypes(#"Renamed Columns3",{{"Document.ElectricityUsageNormalkWh", type number}}),
#"Renamed Columns4" = Table.RenameColumns(#"Changed Type4",{{"Document.ElectricityUsageNormalkWh", "ElectricityUsageNormalkWh"}}),
#"Changed Type5" = Table.TransformColumnTypes(#"Renamed Columns4",{{"Document.dataSource", type text}}),
#"Renamed Columns5" = Table.RenameColumns(#"Changed Type5",{{"Document.dataSource", "DataSource"}}),
#"Changed Type6" = Table.TransformColumnTypes(#"Renamed Columns5",{{"Document.timeStamp", type datetimezone}}),
#"Split Column by Delimiter" = Table.SplitColumn(Table.TransformColumnTypes(#"Changed Type6", {{"Document.timeStamp", type text}}, "en-US"),"Document.timeStamp",Splitter.SplitTextByEachDelimiter({" "}, QuoteStyle.Csv, true),{"Document.timeStamp.1", "Document.timeStamp.2"}),
#"Changed Type7" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Document.timeStamp.1", type datetime}, {"Document.timeStamp.2", type text}}),
#"Renamed Columns6" = Table.RenameColumns(#"Changed Type7",{{"Document.timeStamp.1", "MeasurementDateTime"}, {"Document.timeStamp.2", "MeasurementTimezoneOffset"}}),
#"Sorted Rows" = Table.Sort(#"Renamed Columns6",{{"MeasurementDateTime", Order.Descending}}),
#"Renamed Columns7" = Table.RenameColumns(#"Sorted Rows",{{"ElectricityUsageLowkWh", "Dal"}, {"ElectricityUsageNormalkWh", "Piek"}}),
#"Changed Type8" = Table.TransformColumnTypes(#"Renamed Columns7",{{"EANCODE", type text}}),
#"Sorted Rows1" = Table.Sort(#"Changed Type8",{{"MeasurementDateTime", Order.Ascending}}),
#"Added Custom1" = Table.AddColumn(#"Sorted Rows1", "PercentageContractVermogenKW", each (([Piek]+[Dal])*4)/800),
#"Changed Type9" = Table.TransformColumnTypes(#"Added Custom1",{{"PercentageContractVermogenKW", type number}}),
#"Inserted Date" = Table.AddColumn(#"Changed Type9", "Date", each DateTime.Date([MeasurementDateTime]), type date),
#"Renamed Columns8" = Table.RenameColumns(#"Inserted Date",{{"Date", "MeasurementDate"}}),
#"Inserted Time" = Table.AddColumn(#"Renamed Columns8", "Time", each DateTime.Time([MeasurementDateTime]), type time),
#"Renamed Columns9" = Table.RenameColumns(#"Inserted Time",{{"Time", "MeasurementEndTime"}})
in
#"Renamed Columns9"