Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- The exported Power Query Formula Language (M Language ) can be used with Power Query in Excel
- and Power BI Desktop.
- For Power BI Desktop follow the instructions below:
- 1) Download Power BI Desktop from https://powerbi.microsoft.com/desktop/
- 2) In Power BI Desktop select: 'Get Data' -> 'Blank Query'->'Advanced Query Editor'
- 3) Paste the M Language script into the Advanced Query Editor and select 'Done'
- */
- let AnalyticsQuery =
- let Source = Json.Document(Web.Contents("https://api.loganalytics.io/v1/workspaces/xxxxxxxxxxxxxx/query",
- [Query=[#"query"="
- AppRequests
- | summarize totalCount=sum(ItemCount) by bin(TimeGenerated, 30m), _ResourceId
- | render timechart
- ",#"x-ms-app"="OmsAnalyticsPBI",#"timespan"="P7D",#"prefer"="ai.response-thinning=true"],Timeout=#duration(0,0,4,0)])),
- TypeMap = #table(
- { "AnalyticsTypes", "Type" },
- {
- { "string", Text.Type },
- { "int", Int32.Type },
- { "long", Int64.Type },
- { "real", Double.Type },
- { "timespan", Duration.Type },
- { "datetime", DateTimeZone.Type },
- { "bool", Logical.Type },
- { "guid", Text.Type },
- { "dynamic", Text.Type }
- }),
- DataTable = Source[tables]{0},
- Columns = Table.FromRecords(DataTable[columns]),
- ColumnsWithType = Table.Join(Columns, {"type"}, TypeMap , {"AnalyticsTypes"}),
- Rows = Table.FromRows(DataTable[rows], Columns[name]),
- Table = Table.TransformColumnTypes(Rows, Table.ToList(ColumnsWithType, (c) => { c{0}, c{3}}))
- in
- Table
- in AnalyticsQuery
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement