简体   繁体   English

Power BI - 持久化并在刷新后增量添加数据

[英]Power BI - Persist and incrementally add data after refreshing

There is a web application that produces log statements in Azure Application Insights.在 Azure Application Insights 中有一个 web 应用程序会产生日志语句。 I want to create a Power BI Dashboard that uses that data to create visualizations.我想创建一个使用该数据创建可视化效果的 Power BI 仪表板。 But the data needs to be persisted in Power BI or else I have to query the FULL data each and every time I click on "refresh", which is what is happening right now.但是数据需要保留在 Power BI 中,否则我每次单击“刷新”时都必须查询完整数据,这就是现在正在发生的事情。 That is just too inefficient.那太低效了。 I want to retrieve data for the past couple of days and store/persist that data, and incrementally add new data on top of it each time I click on refresh.我想检索过去几天的数据并存储/保留该数据,并在每次单击刷新时在其上增量添加新数据。

I tried implementing Power BI Incremental Refresh, but that is not applicable to this data source apparently.我尝试实施 Power BI 增量刷新,但这显然不适用于此数据源。

Is there any way to make Incremental Refresh work, or is there any other alternative for this?有什么方法可以使增量刷新工作,或者还有其他选择吗?

I hope someone can help me out with this one.我希望有人能帮我解决这个问题。 Thanks.谢谢。

The query that I generated through Azure Application Insights for Power BI looks as follows: /*我通过 Azure Application Insights for Power BI 生成的查询如下所示:/*

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.applicationinsights.io/v1/apps/15a450/query", 
[Query=[#"query"="traces 
",#"x-ms-app"="AAPBI",#"timespan"="PT12H",#"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

Start with a KQL query that uses a date range, like从使用日期范围的 KQL 查询开始,例如

traces 
| where timestamp >=  datetime(2022-11-20 00:00:00) 
| where timestamp < datetime(2022-11-22 00:00:00)

Then after exporting to a Power Query, integrate the RangeStart and RangeEnd parameters, like this然后导出到 Power Query 后,整合 RangeStart 和 RangeEnd 参数,像这样

: :

let AnalyticsQuery =
let 
    strRangeStart = DateTime.ToText(RangeStart,[Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"]),
    strRangeEnd = DateTime.ToText(RangeEnd,[Format="yyyy-MM-dd'T'HH:mm:ss'Z'", Culture="en-US"]),
    Source = Json.Document(Web.Contents("https://api.applicationinsights.io/v1/apps/60845e27-7ed2-42ef-8ade-25a2fe8236ef/query", 
    [Query=[#"query"="traces 
    | where timestamp >= datetime(" & strRangeStart &") 
    | where timestamp < datetime("& strRangeEnd &")
    ",#"x-ms-app"="AAPBI",#"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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM