Power BI Advanced Series · Real-Time Streaming · by Raushan Ranjan, MCT
Ever wanted your Power BI dashboards to update instantly, reflecting the latest data as it happens? This blog post will guide you through creating "streaming datasets" and "push datasets" in Power BI, and then show you how to feed them real-time data using Python. This approach can be adapted to various real-time analytics scenarios, whether you're monitoring IoT devices, live sales, or financial tickers.
🔸 1. Introduction to Real-time Datasets
💡 What is a Real-time Dataset?
A real-time dataset in Power BI (or any BI tool) allows you to push data continuously (streaming) into the dashboard for instant updates without refreshing the whole report. This is crucial for scenarios where data freshness is paramount.
✅ Types of real-time datasets in Power BI:
| Type | Description | Use Case |
|---|---|---|
| Streaming Dataset | Push-only data (no storage), fast visuals | Live monitoring, IoT |
| Push Dataset | Data gets stored in Power BI | Real-time + historical tracking |
| Hybrid Dataset | Combines Push & Scheduled refresh | Real-time + scheduled needs |
🔸 2. Creating a Streaming Dataset using Python
Let's get hands-on and create a streaming dataset that we'll feed data to using a Python script.
🛠️ Tools Needed:
- Python (e.g., with
requestsorpandaslibraries) - Power BI Service account
- Power BI REST API (specifically, the Streaming Dataset API endpoint)
🧪 Step-by-Step:
✅ Step 1: Create a Streaming Dataset in Power BI Service
- Go to Power BI Service → Your Workspace →
+ Create→Streaming dataset - Select
API→ Configure schema (e.g., add fields liketemperature(Number),humidity(Number),timestamp(DateTime)). - Enable "Historic data analysis" if you want to store the data for later analysis (this turns it into a Hybrid dataset).
- Once created, Power BI will provide a "Push URL". Copy this URL, as you'll need it for your Python script.
✅ Step 2: Push Data Using Python
Now, create a Python script to continuously push data to the streaming dataset URL you copied.
import requests
import json
from datetime import datetime
import random
import time
url = "https://api.powerbi.com/beta/your_streaming_dataset_url" # !!! REPLACE with your actual Push URL !!!
while True:
data = [{
"temperature": random.uniform(20.5, 35.0),
"humidity": random.randint(40, 90),
"timestamp": datetime.now().isoformat()
}]
requests.post(url, data=json.dumps(data),
headers={"Content-Type": "application/json"})
time.sleep(5) # Send data every 5 seconds
🔸 3. Designing Dashboards with Streaming Data Tiles
Once your Python script is running and pushing data, you can visualize it in Power BI.
🧱 Real-time Dashboard Tiles:
- Go to an existing Dashboard in Power BI Service or create a new one.
- Click
+ Add tile→Real-time data. - Choose your streaming dataset from the list.
- Select a visualization type:
Card,Line chart,Bar chart, orGauge. - Bind appropriate fields (e.g.,
timestampon X-axis,temperatureon Y-axis for a line chart). - Configure other visual properties as needed and click
Next/Apply.
📝 Notes:
- You cannot use slicers or filters directly with Streaming-only datasets (because data is not stored).
- If you require interactive features like slicers, filters, or the ability to build reports with historical data, you should use a Push Dataset (or a Hybrid dataset).
🔸 4. Creating a Push Dataset with Real-time Data
✳️ Push Dataset = Real-time updates + data storage
Push datasets offer the best of both worlds: real-time updates for live dashboards AND data storage for historical analysis, reporting, and interactive features. You typically create these programmatically via the Power BI REST API.
✅ Step 1: Create Push Dataset using Power BI REST API or SDK
You'll need an Azure AD access token to authenticate with the Power BI REST API. This usually involves registering an application in Azure AD.
import requests
import json
access_token = "Bearer <your_token_here>" # !!! REPLACE with your actual Azure AD Access Token !!!
url = "https://api.powerbi.com/v1.0/myorg/datasets" # Endpoint to create datasets in your organization
dataset_def = {
"name": "IoT_Device_Data",
"defaultMode": "Push", # This specifies it's a Push dataset
"tables": [
{
"name": "DeviceStats",
"columns": [
{"name": "temperature", "dataType": "Double"},
{"name": "humidity", "dataType": "Int64"},
{"name": "timestamp", "dataType": "DateTime"}
]
}
]
}
res = requests.post(url, headers={
"Content-Type": "application/json",
"Authorization": access_token
}, json=dataset_def)
print(res.json())
After successfully executing the above script, the response will contain the id of the newly created dataset. You can then use this dataset ID to push rows to it using another Power BI REST API endpoint: POST https://api.powerbi.com/v1.0/myorg/datasets/{datasetId}/tables/{tableName}/rows. The data format for pushing rows is similar to the streaming dataset example.
🚀 Real-world Use Cases
Real-time dashboards are invaluable across many industries:
| Domain | Real-time Use |
|---|---|
| Manufacturing | Monitor machine temperature, faults, production line status |
| Sales CRM | Live leads/inquiries dashboard, sales performance by region |
| Healthcare | Patient vitals stream, bed occupancy rates |
| EdTech | Live student login/activity feed, lesson completion rates |
| Finance | Live stock tickers, forex dashboards, transaction monitoring |
🧠 Tips
- For more complex real-time data ingestion and processing, especially at scale, consider using Azure services like Azure Event Hubs (for ingesting millions of events per second) combined with Azure Stream Analytics (for real-time data processing and routing to Power BI).
- For local testing and development, Python scripts are excellent for simulating devices or data sources. You can also use mock sensors or APIs.
- Always use a Push dataset when your real-time dashboard needs interactive features (slicers, filters) or when you need to retain historical data for deeper analysis.
- Ensure proper authentication and authorization when interacting with the Power BI REST API.
Conclusion
Mastering real-time data capabilities in Power BI, especially by leveraging Python for data pushing, opens up a new dimension for your dashboards. You can move beyond static reports to dynamic, instantly updating visualizations that provide immediate insights. This foundation will empower you to build powerful, responsive analytics solutions for a wide array of business needs. Happy streaming!
Quick Knowledge Check
Q1. What is the key difference between a streaming dataset and a push dataset in Power BI Service?
Show Answer
A streaming dataset only supports real-time tile updates — it stores no historical data. Once data passes through, it is gone. A push dataset stores historical rows, supports scheduled refresh, and can power full Power BI reports (not just dashboard tiles). Use streaming for live counters and gauges; use push when you also need charts that span time.
Q2. You create a streaming dataset in Power BI Service. A colleague pins a tile from it to a dashboard and sees values updating every few seconds. Which statement is TRUE?
- A) The data is persisted in a Power BI dataset and can be queried in reports
- B) The tile updates but the data is not stored — historical trend charts are not available
- C) Data is stored for 30 days then auto-deleted
- D) The tile only updates when the user manually refreshes the dashboard
Show Answer
B. A pure streaming dataset does not persist data. The tile updates in near-real-time but there is no stored history. Option A describes a push dataset. Options C and D are incorrect.
Q3. To push data to a Power BI streaming dataset programmatically, which method does the Power BI REST API use?
Show Answer
HTTP POST to the dataset's push URL. The format is POST https://api.powerbi.com/beta/{tenant}/datasets/{datasetId}/rows?key={apiKey}. The body is a JSON array of row objects matching the schema defined when the streaming dataset was created. Python uses requests.post() to call this endpoint.
- Streaming dataset = no history — tiles update live but data is not stored. Use push dataset for real-time tiles + historical reports.
- Push data via REST API — HTTP POST with a JSON row array to the dataset's push URL. Authentication uses the API key set at creation.
- Tiles, not reports — streaming datasets power dashboard tiles only. Full report pages require a push dataset or scheduled refresh dataset.
- Schema matters — define correct field names and types at creation. Mismatched names in POST requests will silently drop data.
- Python is the simplest push client —
requestslibrary + while loop +time.sleep()is all you need.