Real-time charts and graphs take business intelligence to a new level, and PubNub is excited to make your data streams available on the Microsoft Power BI platform. In most any industry use case (Automotive, Energy, Manufacturing, Medical, Retail, Smart City, Telecommunications, etc.), you can use PubNub to feed your real-time data into Microsoft Power BI.
In this tutorial, we’ll document how to feed your PubNub data streams into Power BI, resulting in some really impressive real-time charting functionality!
We’ll use “demo” API keys to get off the ground quickly, but if you wish to use your own PubNub data or if you don’t yet have an account, go ahead and sign up now. Create an App, and then a Keyset, and you’ll be ready to go.
To get access to Power BI:
Power BI can chart any PubNub real-time data stream, as long as the payload is a JSON object. In addition, PowerBI supports not only flat objects, but also those with hierarchy (objects within objects). Neat, huh?
In reality, you can use your very own PubNub data streams to populate Power BI charts, but for the sake of simplicity, we’ll use a demo datastream called “sensor-network.”
Our “sensor-network” datastream object contains real-time environmental data from five different cities, with attributes of:
In JSON, the native format PubNub communicates in, it will look similar to this snippet:
{ "timestamp": "2016-08-23T22:31:40.255Z", "Novato": { "geo": "38.1074° N, 122.5697° W", "temperature": { "F": "99.9", "C": "37.7" }, "humidity": "40.965", "barometric": "1011.8", "pollution": 3, "uv": 9.5, "noise": "28.75962" }, "Redmond": { "geo": "47.6740° N, 122.1215° W", ... } }
Now that you have an overview of what our sample data looks like, the next step is to create data visualizations.
Creating our first Power BI Dashboard, PubNub Data Source, and Chart can be done quickly and nearly simultaneously. Let’s jump right in and begin by defining a new Dashboard!
If you’ve already setup Power BI in the past, then when you login, go ahead and skip to the Previously Setup Account section below.
If this is your first time logging in to Power BI, follow the Newly Setup Account instructions below.
When you first login to Power BI, you will be presented with the Welcome screen.
The Files menu appears.
Proceed to the Previously Setup Account section below to continue.
Once expanded, the left menu should look similar to this:
NOTE: If this your first time using Power BI, the three horizontal lines may not be visible. If this is the case, instead, click Sample Data.
A text field will appear.
You’ll now be viewing the empty PubNub Sensor Cluster Dashboard.
Next, lets add a Tile to the Dashboard.
The Add tile panel appears.
The Add a custom streaming data tile panel appears. This screen is where we will bring in the actual PubNub Data Stream, credentials and all, into Power BI, as a streaming dataset.
To add PubNub as a streaming dataset for your Power BI dashboard, click manage data.
The Streaming data page opens.
The New streaming dataset panel opens.
Upon clicking Next, you should see an example schema and example object representation of the data.
NOTE: This dataset is large — be sure to scroll all the way down to get a comprehensive look at the information presented.
The Streaming Data page appears again, but this time, with our PubNub Sensor Network displayed as a defined entry.
Now that we’ve created the streaming dataset, we have the foundation to build our visualizations on top of it.
Power BI provides many different chart types for real-time streaming data. They include:
Each chart type has its niche — more details on the various chart types can be found within Power BI documentation, but I’ve assembled a brief summary of when to use each one.
When the latest number value of a metric is the most important thing to know, use a card.
Line charts display data points, connected together by lines. A great use of line charts is to visualize data changes across a time period.
Column charts display data relative to a horizontal (x-axis) reference point, and bar charts display data relative to a vertical (y-axis) reference point. Both are great for displaying changing minx and maxes. “Clustered” just means that you can display many values together (for example, “North American Sales” and “Asia Sales”) together on the same tile.
A gauge chart shows a min and max of two extremes, and where your value lies between the two. These are best used when it’s important to know where you stand in the midst of two extremes.
NOTE: Although Power BI provides a wide-range of industry-leading visualization features, the purpose of this post isn’t to go in-depth into all of them at once. Instead, we’ll begin with simple PubNub-driven examples, and based on user feedback, we will be excited to add more blog post installments with more varying, user-requested topics. As such, as you have fun learning about PubNub visualizations through Power BI, take some notes on additional areas of interest, and email them to use at support@pubnub.com.
Now that we know our options, let’s begin with a simple Card example.
The Add tile panel appears.
The Visualization Type dropdown will appear.
A dropdown will appear with attributes of the PubNub data stream.
Your screen should look similar to below:
Congrats! You’ve created your first real-time visualizations with Power BI Cards powered by a PubNub data stream!
Next, we’ll experiment with Line Charts.
The Visualization Type dropdown will appear.
You should now see the humidity in Redmond as a function of time in the preview. But for bonus points, let’s also plot the humidity in San Francisco as well.
Your screen should similar to the example below:
The line chart appears next to the last card we made. Let’s resize and arrange our new line chart for purely aesthetic purposes.
Congratulations are in order once again, as now, we have a two value Line Chart added to our Dashboard!
Next, let’s create some Bar and Column charts.
The Visualization Type dropdown will appear.
Repeat the above step for each other city’s temperature in Fahrenheit.
We now have the a temperature bar chart. Next, let’s do a variation of the same data, but in a column chart.
The Visualization Type dropdown will appear.
Repeat the above step for each other city’s temperature in Celsius.
In the column chart example, we omitted the x-axis (known simply as the axis). By adding an axis value (in this case, the timestamp), we can then show multiple instances of the chart relative to the axis value, within a time window.
The Axis dropdown will appear.
We now have two versions of the same data visualized very differently. Two units of measure are shown in two charting formats, one, with the bar chart’s values displayed in-place for an always current view of the data, and the other as a column chart, the last five seconds worth displayed.
For our final chart, lets create a gauge chart to compare the noise levels of three cities at once.
The Visualization Type dropdown will appear.
This will make it so the gauge indicates the noise in Honolulu.
This will re-scale the gauge at the min-point, so the min value in the scale represents the current noise level in Novato.
This will re-scale the gauge at the max-point, so the max value in the scale represents the current noise level in Chennai.
The gauge appears next to the last chart we made. Let’s resize and arrange our gauge for purely aesthetic purposes.
And there you have it, a crash-course in using PubNub real-time data streams with Power BI!
We hope you enjoyed this tutorial! Your feedback is really important — tell us what you’d like to see us focus on for our next installment of Power BI and PubNub blog posts. Email your requests to support@pubnub.com, and we’ll be looking forward to your feedback!
There are common underlying technologies for a dating app, and in this post, we’ll talk about the major technologies and designs...
Michael Carroll
How to use geohashing, JavaScript, Google Maps API, and BART API to build a real-time public transit schedule app.
Michael Carroll
How to track and stream real-time vehicle location on a live-updating map using EON, JavaScript, and the Mapbox API.
Michael Carroll