Apr 11, 2018

Streaming with Power BI


Edited: Apr 11, 2018


What if you need to present real-time data in a Power BI dashboard?


In this post I will give you an overview of two different approaches to address the requirements for real-time reporting.



Power BI Streaming

First and easier option is to create a Streaming dataset in Power BI, and then write some small code to push data directly into this dataset.


Notes & Limitations:

  • With “historic data analysis” option ON, data will be retained forever and available on reports and alerts from dashboard tiles. Rows can also be removed using the API.

  • With “historic data analysis” option OFF, data will not be retained, and Power BI will keep up to 200k rows, FIFO.

  • 120 POST rows requests per minute.



Azure Stream Analytics

Another option is to use Azure and then ingest data via Events Hub.



Output will be the Power BI dataset “cbiStreamAnalytics”.


And the code?

Simple! A console C# application is the easiest way to test and push data to both datasets.

// Push to Power BI
var postToPowerBi = HttpPostAsync(measureTypeItem.powerBiPostUrl, "[" + jsonString + "]"); 
// Push to Azure Stream Analytics 
EventHubClient client = EventHubClient.CreateFromConnectionString(ConnectionStringStreamAnalytics, "cbistreaminghubpbi");
client.Send(new EventData(Encoding.UTF8.GetBytes(jsonString)));                     



Here is an example of a Power BI dashboard showing real-time data from both datasets to compare latency.



New Posts
  • Rail companies use data analytics daily to run everything from operations and maintenance to making key business decisions based on intelligence from the collected data. In the last 10 years, the emergence of the digital railway has incurred a demand for Big Data techniques to respond to an overwhelming surge in data collection capabilities and speed. Largely, the UK rail sector has embraced this development and has begun implementing Big Data analysis and Data Science technologies to stay ahead of competitors and provide a better modern service to their customers while maintaining assets and efficiency. The Digitisation of Rail Historically, the rail industry has been criticised for lack of innovation, falling behind the times in many areas and failing to capitalise on emerging technologies. Certainly, this has been improving in recent years. Today, companies collect vast amounts of data from rail stakeholders who provide intelligence via computer systems, the Internet of Things (IoT) and Cloud computing, which constitutes the move towards ‘smart railways´. To ensure the data’s business potential is realised and optimised, companies analyse and work to unlock the potential of the collected data, as Porterbrook, the train leasing company have done in the last year. The digitalisation of rail also offers new services for customers. Mobile ticketing has undoubtedly revolutionised the travel experience and new technologies such as the Trainline´s voice activated customer communication greatly enhances the way in which customers interact with companies. Undoubtedly, digital technology governs a great deal of rail customers behaviours including purchasing, expectations, operator information and reservations.  These leaps in digitisation in rail have led to improved monitoring of assets, automation in operations, and customer interactions, and as the technology becomes readily available and cheaper, the digital railway nears reality. Where Has the UK Rail Industry Been failing? While digitisation has provided the means for innovation and improvement of operations, recent reports indicate performance of trains services have not met expectations. Since the privatisation of Britain’s Rail Network, the government predicted that more competition between the companies in the sector would lead to a better service. In fact, the opposite has been true as ticket prices have risen, and lateness hit a 13 year high in the UK in 2018.  The issue is that while UK rail has certainly improved the maintenance and delivery of rolling stock assets, it is still way behind other countries in customer experience. Customers simply do not trust rail companies to deliver on time, and why should they given recent statistics? According to the Office of Rail and Road , 86.3% of trains arrived on time in the UK. In comparison, the Spanish high-speed network achieves 98.5% punctuality. Dan Ascher´s BBC article suggests that future rail companies should be underpinned by punctuality and excellent customer experience.  Many argue the root of this problem is a reluctancy to invest in smart technology combined with a lack of data science workers within rail companies. Indeed, it will require a change of mindsets and business models as well as significant financial investment in rail digitisation to improve operations and rekindle customer faith. Improvements will also need to be made into customer interactions utilising new technology to provide up to date, accurate and accessible information for passengers. How Can Data Science Improve the Rail Industry? Data Scientists extract meaning from and interpret large quantities of data. In rail, this includes all the current and emerging data used by railways to help monitor infrastructure and equipment and optimise maintenance to improve safety. “Big data analytics have the potential to influence several dimensions of the railway sector and can overcome organisational, operational and technical complexities, including economic and human effects and information handling.”  - Professors D. Galar, U. Kumar and R. Karim at Luleå University of Technology. Operations and maintenance are areas generating considerable excitement for rail companies due to self-learning and smart systems that predict failure, make diagnoses and trigger maintenance actions. Companies looking to introduce smart technology systems require data scientists to build these predictive Machine Learning (ML) models and provide a service that helps uncover the potential of the data. ML models and data science services that predict delays across the network are popular because they can: Help make savings on delay-repay compensation Identify interventions to minimise disruption Inform better train scheduling Inform better maintenance scheduling Improve public performance metrics To utilise the insights from these models, the right platforms needs to be well utilised for a company's specific data sets and requirements. Data scientists and rail industry experts should seek to collaborate to build the necessary algorithms and analysis tools to deliver the most effective solutions for the business' needs. The UK rail leasing company Porterbrook recently consulted Elastacloud to realise these advantages. Read the full case study here. Follow us: @elastacloud https://www.linkedin.com/company/2451879
  • Maintaining sufficient quantities of drinking water on board an underway vessel is a critical safety element for the crew members and general operation of the vessel. While sea water may be satisfactory for cleaning decks and flushing toilets, fresh water must be maintained for human consumption and power generation. Crew members face multiple challenges in optimising potable water quantity planning, including trip variables such as voyage length, speed, weather conditions, consumption rates, passenger volumes and fuel costs. When optimised, the savings can be substantial for ship operators. As an example, the weight and space created by eliminating excess water tanks can be used to store extra fuel or cargo, leading to significant savings per year. By analysing fleet onboard data sources such as ship type (e.g. bulk carrier, container ship), the expected number of crew and passengers, voyage length, anticipated speed and weather conditions combined with the onboard systems capability to generate potable water a prediction can be made for the volume of potable water required for the voyage. During the voyage, live onboard sensor data tracks actual water consumption, temperature patterns, and travel speed to adjust bunkering and docking locations as needed. When deviations occur, crew members receive early warning alerts and are rerouted to nearby distilling sites, ensuring the safety of all crew and passengers aboard. The machine learning algorithms continue to adapt and gain accuracy with each voyage.
  • Have you considered publishing and integrating your Power BI reports, dashboards and tiles into your custom application? In this post I will give you an overview of Power BI Embedded, and how far you can use it as the reporting and analytics tool for your application. What is Power BI Embedded? Similar to other apps built on Microsoft Azure, like Machine Learning and IoT, Power BI Embedded enables ISVs to integrate visuals into their apps, allowing their customers to make quick decisions in context and with confidence from any device. Your customers don’t need to login to Power BI or to have a Pro license. Image source: https://azure.microsoft.com/en-gb/services/power-bi-embedded/ Reasons to use Power BI Embedded Some key reasons you should consider using Power BI Embedded: You want your customer to feel they are inside your application, not in Power BI. You want to keep your developers focused on your solution, instead of spending development time building reports and analytics features. You don’t want to ask all your customers to acquire a Power BI Pro License. How to Start What you need to start using Power BI Embedded: 1. A Power BI user with a Pro License This will be the master account you will use to publish visuals and also to connect your application to Power BI, acting as a proxy account. 2. A Power BI App Workspace This is where your reports will be published to. You can have a single workspace with all your visuals or different workspaces for each customer. 3. Azure Capacity This is the dedicated resource in Azure to run your visuals, using an hourly metered model. You can choose to pause and resume the service to control the billing and easily scale up or down selecting a SKU that fits your needs. 4. Some Code Of course… some coding is also required using the Power BI APIs and Java Script SDK to generate a token for your reports, dashboards and tiles, and to load these visuals inside your application. Your code can also interact with your visuals, changing pages, setting filters, etc. The image below illustrates how a report is processed with Power BI Embedded Image source: https://docs.microsoft.com/en-us/power-bi/developer/embedding Access Levels Your application controls the authentication and authorisation, restricting the data access. You can use a different set of visuals for each customer or to share the same visuals across all customer together with some dynamic filters to set data access levels. Multiple and different users can work with the same visuals, all seeing different data using row-level security. How far can I go with Power BI Embedded? Most of the functionalities already available in Power BI Service (Web) are also available in Power BI Embedded. You can use any visual from Power BI store or even build your own custom visualisations to address some specific requirements. We have clients exploring this to a maximum, using custom visualisations to do some clever integration from the visual context back to their custom application, via web service calls. References Here are some useful links and resources Power BI pricing: https://powerbi.microsoft.com/en-us/pricing/ Azure capacity pricing: https://azure.microsoft.com/en-gb/pricing/details/power-bi-embedded/ How to create a Power BI Embedded capacity: https://docs.microsoft.com/en-us/azure/power-bi-embedded/create-capacity How to embed your Power BI dashboards, reports and tiles: https://powerbi.microsoft.com/documentation/powerbi-developer-embedding-content/ Source code examples: https://powerbi.microsoft.com/documentation/powerbi-developer-embed-sample-app-owns-data/