Overview: In this post we go through the intricacies of creating a SQL Azure storage, mapping it to a Power BI report, getting data into it, designing it, publishing it online and finally embedding to a website. These steps are generally required when starting to create a report and embedding it to a website

For creation of the Power BI report, first we have to select a Data Source for it. It can also be a file, BLOB Storage, Storage account, SQL Azure Database, Access Database, NoSQL Databases like DocumentDB, Microsoft’s HD Insight, etc.  All these data stores can be created in an azure subscription.

Gotchas to be aware:

  1. Power BI Reports can also be created using Streaming Datasets like Azure Stream Analytics, but at the time of writing this article, power BI Embed doesn’t support rendering reports that are created to display streaming data. We shall therefore be going through report creation and embedding using non-streaming data sources like SQL Azure.
  2. SQL Azure supports creating reports using Power BI Desktop version. It doesn’t support directly connecting to the Online version. So, first let’s download Power BI Desktop to be able to connect to SQL Azure and create a report out of it. Desktop version can be downloaded by going to Downloads section in Power BI (powerbi.microsoft.com) or going to the databases section in it and selecting SQL Azure. See the screenshot below.

2016-12-16-8

Let’s get started.

Steps:

  1. Go to the Azure portal (portal.azure.com), sign in with company or work account (if not signed in already), click on plus sign on left menu bar.
  1. Go the Databases section and select ‘SQL Database’ from the options

2016-12-17-1Fig 2: Selecting SQL Database from Databases section

  1. Create SQL Database – Fill unique Database Name, Server, Pricing Tier, etc. for the SQL Database and click on Create button at the bottom.

2016-12-17-2Fig3: Create Database

  1. Once the database gets created, it will be shown on the Azure Dashboard along with all its properties.
  1. Data injection, There are many ways to pump the data into the database. I’m skipping the details on this step to keep us stick to the objective of this blog post.  (BTW, I got the data from my simulated IoT devices -> IoT Hub -> Stream Analytics -> Database.)
  1. Open Power Bi Desktop, a blank report layout automatically opens. Click on Get Data -> Azure -> Microsoft Azure SQL Database. Click on Connect.

2016-12-16-9Fig 4: Get Data for Power BI report

  1. Copy the server name of the database from Azure portal, created earlier.
  2. Use the Database Server Name thus copied and paste it in the popup asking for the Server name while establishing a connection from the report to the database. Click on OK.

Fig 5: Paste SQL Server Database Name

  1. The Database Navigator will come up showing the Database and its associated tables. The data will also be shown alongside.

2016-12-16-12Fig 6: Database Navigator showing database table and their data

  1. Click on the Table from which you want to fetch the fields. Its data, if loaded, will be shown alongside. Click on ‘Load’.

2016-12-16-13Fig 7: Load the Table data

  1. Once the database is loaded, the table fields will appear on the right side pane of the report under Fields tab
  1. Firstly, click on the field for which the value is to be plotted. Single bar will appear.

2016-12-16-16Fig 8: Take the value field for plotting

  1. Now, select the different fields as per the type of report being plotted.
    In this session we are taking an example of an Area report, so we require the Latitude and Longitude. Drag and drop the lat, long fields to the Latitude, Longitude. Click on both fields and set them to ‘Don’t Summarize’ so that Power BI does not put an aggregate on the latitude & longitude fields.
    Also click on Size and take an aggregate, possibly Average to represent the average of the values for a particular latitude-longitude pair.

2016-12-16-17Fig 9: Don’t Summarize Latitude-Longitude fields

2016-12-16-18Fig 10: Take Average (aggregate) of Size column

  1. Currently we can see that all bubbles are coming of same color irrespective of their sizes (average values). To show a distinction between them, drag the same field which is in Size column from Fields tab and put it in ‘Color Saturation’. Click on it and take its Average.

2016-12-16-19Fig 11: Adding Color Saturation

  1. Click on the roller icon, click on Data Colors and set Diverging to ‘On’, give different colors to the Minimum, Center and Maximum levels. Also set values for the 3 levels against which they will be compared.

2016-12-16-20Fig 12: Setting Diverging Colors and Min, max, Center Value Ranges

  1. Save the report in your hard drive. It will have a .pbix extension.
  2. For the report to be available online, we need to publish it to the online service. Click on Publish icon at the top to publish the report to the Power Bi Online service.
  3. The report will take a few seconds to publish to the online service.
  4. Once report is published, it will show a success message.

2016-12-16-24Fig 13: Report published successfully

  1. Now open Power BI online (powerbi.microsoft.com) to access the report. We can view our report in the Reports section and it’s dataset in the Dataset section.

2016-12-16-25Fig 14: Open report in Power BI Online

  1. To view the report in a dashboard, we have to pin it to an existing one or create a new one. Click on the small pin at the top right of the report and choose an existing Dashboard from the drop-down and click on Pin.

2016-12-16-26Fig 15: Pin report to dashboard

  1. Go the dashboard to which the report has been pinned, click on the top right of the report and the below visual will come up with the original name of the report. Click on the Pen icon to Edit the report Tile.
  2. By default reports come with the titles set as the field names. Change the Title/Subtitle of the report as required.

2016-12-16-28Fig 16: Changing Report title/ subtitle

  1. To embed the code, we need to publish the report to web. For this open the report in Power BI Online. Click on File -> Publish to Web.

2016-12-16-29Fig 17: Publish report to Web

  1. Click on ‘Create Embed Code’ in the popup which open up.

2016-12-16-30Fig 18: Create Embed Code

  1. Click on ‘Publish’ to fetch the embedded code.

2016-12-16-31

Fig 19: Publish to get embedded code

  1. A success message with embedded code having email link and web link will appear. We can use these links to embed our report in a website. We can also adjust the report size to show the report in a size that will fit in our website.

2016-12-16-32Fig 20: Web and Email Embedded links with Size adjustments

  1. Copy the iframe link from the above and paste it to your website (HTML). You can change height-width of iframe to suit your website

2016-12-16-33Fig 21: Add embedded iframe to website

  1. Open the HTML page in your browser. The report should open in your page as per the size adjustments.

2016-12-16-34Fig 22: Open website with embedded report in browser

Conclusion: After going through the series of steps, we can see a definite mapping between SQL Azure and Power BI which can be managed by the same Azure subscription. Also, reports created using SQL Azure as a data source are not exactly real-time but can hold thousands of records which keep refreshing after a certain amount of time. So, if we don’t have requirement for real-time data analytics but want to have a large pool of data, we can very well go in for SQL Azure and use it in our Power BI reports. Embedding the reports and making them live isn’t too much of a hassle and we can very well embed multiple meaningful reports to our website dashboard to make it look more comprehensive and elegant.

Leave a Reply

Your email address will not be published. Required fields are marked *