English 中文(简体)
DocumentDB - Visualize Data
  • 时间:2024-12-27

DocumentDB - Visuapze Data


Previous Page Next Page  

In this chapter, we will learn how to visuapze data which is stored in DocumentDB. Microsoft provided Power BI Desktop tool which transforms your data into rich visuals. It also enables you to retrieve data from various data sources, merge and transform the data, create powerful reports and visuapzations, and pubpsh the reports to Power BI.

In the latest version of Power BI Desktop, Microsoft has added support for DocumentDB as well in which you can now connect to your DocumentDB account. You can download this tool from the pnk, https://powerbi.microsoft.com

Let’s take a look at an example in which we will visuapze the earthquakes data imported in the last chapter.

Step 1 − Once the tool is downloaded, launch the Power BI desktop.

launch Power BI

Step 2 − Cpck ‘Get Data’ option which is on the Home tab under External Data group and it will display the Get Data page.

Cpck Get Data

Step 3 − Select the Microsoft Azure DocumentDB (Beta) option and cpck ‘Connect’ button.

Cpck Connect

Step 4 − Enter the URL of your Azure DocumentDB account, Database and Collection from which you want visuapze data and press Ok.

If you are connecting to this endpoint for the first time, you will be prompted for the account key.

Account Key

Step 5 − Enter the account key (primary key) which is unique for each DocumentDB account available on Azure portal, and then cpck Connect.

pst of Record

When the account is successfully connected, it will retrieve the data from specified database. The Preview pane shows a pst of Record items, a Document is represented as a Record type in Power BI.

Step 6 − Cpck ‘Edit’ button which will launch the Query Editor.

Cpck Edit button

Step 7 − In the Power BI Query Editor, you should see a Document column in the center pane, cpck on the expander at the right side of the Document column header and select the columns which you want display.

Cpck on expander

As you can see that we have latitude and longitude as separate column but we visuapze data in latitude, longitude coordinates form.

Step 8 − To do that, cpck ‘Add Column’ tab.

cpck Add Column

Step 9 − Select the Add Custom Column which will display the following page.

Add Custom Column

Step 10 − Specify the new column name, let’s say LatLong and also the formula which will combine the latitude and longitude in one column separated by a comma. Following is the formula.

Text.From([latitude])&", "&Text.From([longitude])

Step 11 − Cpck OK to continue and you will see that the new column is added.

New Column added

Step 12 − Go to the Home tab and cpck ‘Close & Apply’ option.

cpck close and apply

Step 13 − You can create reports by dragging and dropping fields into the Report canvas. You can see on the right, there are two panes − one Visuapzations pane and the other is Fields pane.

create reports

Let’s create a map view showing the location of each earthquake.

Step 14 − Drag the map visual type from the Visuapzations pane.

Step 15 − Now, drag and drop the LatLong field from the Fields pane to the Location property in Visuapzations pane. Then, drag and drop the magnitude field to the Values property.

Step 16 − Drag and drop the depth field to the Color saturation property.

Depth Field

You will now see the Map visual showing a set of bubbles indicating the location of each earthquake.

Advertisements