Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
I have a requirement where I need to send the continuous stream of data by Python Script to Power Bi to build a Dashboard. For example I can say like a Stock Market dashboard where the Price of the stock keeps on changing every second.
I am doing POC on this and I was trying to get this script mentioned below to generate the random data and send that data to Power BI
import random
import time
from datetime import datetime
import pandas as pd
# Initialize an empty DataFrame
columns = ['DealNumber', 'DealDateTime', 'DealCountry', 'Amount']
data_frame = pd.DataFrame(columns=columns)
# Function to generate random data for the fields
def generate_random_data():
deal_number = random.randint(10000, 99999) # Random 5-digit DealNumber
deal_date_time = datetime.utcnow().strftime("%Y-%m-%dT%H:%M:%S.%fZ") # Current UTC timestamp in ISO 8601 format
deal_country = random.choice(["India", "USA", "UK", "Canada"]) # Random country
amount = round(random.uniform(100.0, 1000.0), 2) # Random amount between 100 and 1000 with 2 decimal places
return [deal_number, deal_date_time, deal_country, amount]
# Infinite loop to generate data every 5 seconds and append to the DataFrame
while True:
random_data = generate_random_data()
data_frame.loc[len(data_frame)] = random_data
print(data_frame)
time.sleep(5) # Wait for 5 seconds before generating the next set of data
When I try to connect this code to Power BI it gets stuck on this message below as I am generating random data every 5 second.
Please suggest how I can resolve this issue or any python example that can show continuous data so that power bi can utilize that data
Hi @Anonymous,
I have already explored the streaming dataset and it is very much alligned with my requirement but I have a hard stop at that because Streaming dataset or Push dataset only allow Add or Delete. We need update feature as well to update the record previously send to Push dataset, but update option is not available.
Please advice.
Hi @suneet_madahar,
In my opinion, I think power bi desktop not suitable to handle with live data. Perhaps you can consider to deploy a steaming dataset to respond and display the live data tile on power bi service side.
Real-time streaming in Power BI - Power BI | Microsoft Learn
Regards,
Xiaoxin Sheng
User | Count |
---|---|
5 | |
4 | |
3 | |
2 | |
2 |
User | Count |
---|---|
8 | |
6 | |
4 | |
4 | |
4 |