Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
suneet_madahar
Regular Visitor

Need help in generating continuous Data using the Python Scrip and then send to Power BI

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(1000099999)  # 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.01000.0), 2)  # Random amount between 100 and 1000 with 2 decimal places

    return [deal_numberdeal_date_timedeal_countryamount]

# 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. 

 

suneet_madahar_0-1704726510657.png

 

 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

2 REPLIES 2
suneet_madahar
Regular Visitor

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.

Anonymous
Not applicable

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

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.