使用已导入到 Power BI 中的查询来可视化数据Visualize data using a query imported into Power BI

Azure 数据资源管理器是一项快速且高度可缩放的数据探索服务,适用于日志和遥测数据。Azure Data Explorer is a fast and highly scalable data exploration service for log and telemetry data. Power BI 是一种业务分析解决方案,可以用来可视化数据,并在组织内共享结果。Power BI is a business analytics solution that lets you visualize your data and share the results across your organization.

Azure 数据资源管理器提供三个可以在 Power BI 中连接到数据的选项:使用内置连接器、从 Azure 数据资源管理器导入查询,或者使用 SQL 查询。Azure Data Explorer provides three options for connecting to data in Power BI: use the built-in connector, import a query from Azure Data Explorer, or use a SQL query. 本快速入门介绍如何导入查询,以便获取数据并在 Power BI 报表中直观显示这些数据。This article shows you how to import a query so that you can get data and visualize it in a Power BI report.

如果没有 Azure 订阅,可在开始前创建一个 试用帐户If you don't have an Azure subscription, create a trial account before you begin.

必备条件Prerequisites

若要完成本文,需要满足以下条件:You need the following to complete this article:

从 Azure 数据资源管理器获取数据Get data from Azure Data Explorer

首先,在 Azure 数据资源管理器桌面应用中创建一个查询并将其导出,以便在 Power BI 中使用。First, you create a query in the Azure Data Explorer desktop app and export it for use in Power BI. 然后,连接到 Azure 数据资源管理器帮助群集,并从 StormEvents 表引入一部分数据。Then, you connect to the Azure Data Explorer help cluster, and bring in a subset of the data from the StormEvents table. StormEvents 示例数据集包含国家环境信息中心中与天气相关的数据。The StormEvents sample data set contains weather-related data from the National Centers for Environmental Information.

  1. 在浏览器中转到 https://help.kusto.chinacloudapi.cn/,以便启动 Azure 数据资源管理器桌面应用。In a browser, go to https://help.kusto.chinacloudapi.cn/ to launch the Azure Data Explorer desktop app.

  2. 在桌面应用中,将以下查询复制到右上查询窗口中,然后运行该查询。In the desktop app, copy the following query into the upper-right query window then run it.

    StormEvents
    | sort by DamageCrops desc
    | take 1000
    

    结果集的头几行应该如下图所示。The first few rows of the result set should look similar to the following image.

    查询结果

  3. 在“工具”选项卡上选择“对 Power BI 进行查询”,然后选择“确定”。 On the Tools tab, select Query to Power BI then OK.

    导出查询

  4. 在 Power BI Desktop 的“主页”选项卡上,选择“获取数据”,然后选择“空白查询” 。In Power BI Desktop, on the Home tab, select Get Data then Blank query.

    获取数据

  5. 在 Power Query 编辑器的“主页”选项卡上,选择“高级编辑器”。 In the Power Query Editor, on the Home tab, select Advanced editor.

  6. 在“高级编辑器”窗口中,粘贴导出的查询,然后选择“完成”。 In the Advanced editor window, paste the query you exported then select Done.

    粘贴查询

  7. 在 Power Query 编辑器主窗口中,选择“编辑凭据” 。In the main Power Query Editor window, select Edit credentials. 选择“组织帐户”,登录,然后选择“连接”。 Select Organizational account, sign in, then select Connect.

    编辑凭据

  8. 在“主页” 选项卡上,选择“关闭并应用” 。On the Home tab, select Close & Apply.

    关闭并应用

在报表中将数据可视化Visualize data in a report

Power BI Desktop 中有了数据以后,即可创建基于该数据的报表。Now that you have data in Power BI Desktop, you can create reports based on that data. 将创建一个简单的包含柱状图的报表,以便按州显示作物损坏情况。You'll create a simple report with a column chart that shows crop damage by state.

  1. 在 Power BI 主窗口左侧,选择报表视图。On the left side of the main Power BI window, select the report view.

    报表视图

  2. 在“可视化” 窗格中,选择“簇状柱形图”。In the VISUALIZATIONS pane, select the clustered column chart.

    添加柱形图

    会向画布添加一个空白图。A blank chart is added to the canvas.

    空白图

  3. 在“字段” 列表中,选择“DamageCrops” 和“州” 。In the FIELDS list, select DamageCrops and State.

    选择字段

    现在已有一张图表,显示表中最前面 1000 行对应的作物损坏情况。You now have a chart that shows the damage to crops for the top 1000 rows in the table.

    作物损坏情况(按州)

  4. 保存报表。Save the report.

清理资源Clean up resources

如果不再需要为本文创建的报表,请删除 Power BI Desktop (.pbix) 文件。If you no longer need the report you created for this article, delete the Power BI Desktop (.pbix) file.

后续步骤Next steps

使用 Power BI 的 Azure 数据资源管理器连接器直观显示数据Visualize data using the Azure Data Explorer connector for Power BI