Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Dear Experts,
I have a dashboard page that shows a custom line chart from Power BI python scripts. Everything works as intended on Power BI desktop.
However, every time I tried to view that report page on app.powerbi.com, I get the following error.
Here is my python script.
FYI, my dataframe "dataset" has no float or decimals, all int.
My dataframe,
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import math
fig, ax = plt.subplots()
sns.lineplot(ax=ax, data = dataset, x='Year_month', y='Budget', hue='office', legend=None)
sns.lineplot(ax=ax, data = dataset, x='Year_month', y='Actual', hue='office', legend=None, linestyle='--')
cust_anno = ['line1','line2','line3','line4','line5','line6','line7','line8','line9','line10','line11','line12']
for line, name in zip(ax.lines, cust_anno)
y = line.get_ydata()
x = line.get_xdata()
if len(y)>0:
ax.annotate(name, xy=(x[-1],y[-1]), xycoords=(ax.get_xaxis_transform(), ax.get_yaxis_transform()), ha="left", va='center', color=line.get_color())
print(ax.get_xaxis_transform())
plt.xticks(dataset.Year_month, dataset.Year_month, rotation=45, ha='right')
plt.tight_layout(pad=0, w_pad=0, h_pad=0)
plt.show()
and Here is my Power BI desktop showing line chart generated by Python as intended.
Thank you very much for your time and helps in advance.
Update 1: added "dataset" sample
Hi All!
I see the thread has been running from 2021-2022 but even as of today, we've encountered similar issue with the Python code implemented into a power BI visual.
Any resolution on this?
Please let me know.
Thanks in advance!
I have a dashboard page that shows a custom line chart from Power BI python scripts. Everything works as intended on Power BI desktop. However, whenever I tried to view that report page on app.powerbi.com, I get the following error.
Activity ID: 7e04e7e1-9039-4ad5-a983-093700045bb7
Request ID: a98b65bc-1355-4585-1a40-b54cd6cb0e9d
Correlation ID: 7bd5db43-9922-540b-a16a-754a83abb0dc
Time: Sun Jun 27 2021 03:19:27 GMT+0630 (Myanmar Time)
Service version: 13.0.16239.61
Client version: 2106.1.06599-train
Cluster URI: https://wabi-south-east-asia-redirect.analysis.windows.net/
Here is my python script.
FYI, my dataframe "dataset" has no float or decimals, all int.
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import math
fig, ax = plt.subplots()
sns.lineplot(ax=ax, data = dataset, x='Year_month', y='Budget', hue='office', legend=None)
sns.lineplot(ax=ax, data = dataset, x='Year_month', y='Actual', hue='office', legend=None, linestyle='--')
cust_anno = ['line1','line2','line3','line4','line5','line6','line7','line8','line9','line10','line11','line12']
for line, name in zip(ax.lines, cust_anno😞
y = line.get_ydata()
x = line.get_xdata()
if len(y)>0:
ax.annotate(name, xy=(x[-1],y[-1]), xycoords=(ax.get_xaxis_transform(), ax.get_yaxis_transform()), ha="left", va='center', color=line.get_color())
print(ax.get_xaxis_transform())
plt.xticks(dataset.Year_month, dataset.Year_month, rotation=45, ha='right')
plt.tight_layout(pad=0, w_pad=0, h_pad=0)
plt.show()
and Here is my Power BI desktop showing line chart as intended
Any help would be appreciated.
Hi, @zawlynn
I'm sorry that I haven't found any relevant threads.
Please submit a ticket to Microsoft Support to check if it is a known issue caused by a bug in Power BI Service.
Best Regards,
Community Support Team _ Eason
@v-easonf-msft I will open a ticket regarding this issue. Meanwhile, what should I do with this topic? Should I mark your reply as the solution?
Hi, @zawlynn
If you get any feedback or solutions from MS, please kindly share it here.
You can accept your reply as a solution to close this thread so that other community members can easily find a solution when they encounter the same issue.
Best Regards,
Community Support Team _ Eason
Hi @zawlynn
Can you confirm that your python script uses the supported python packages in the Power BI Service as per the details below:
Python visualizations in Power BI Service | Microsoft Power BI Blog | Microsoft Power BI
If it using another package it will not work.
Dear GilbertQ, I have checked for Power BI supporting python packages and yes, all packages are support by Power BI.
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
import math
Hi @zawlynn ,
I don't have good knowledge about Python, but you can refer to https://stackoverflow.com/questions/52678108/typeerror-cannot-cast-array-data-from-dtypeu1-to-dtypef...
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hello,
that stackoverflow topic issue is similar but we have different scenarios,
ax.annotate(name, xy=(x[-1],y[-1]), xycoords=(ax.get_xaxis_transform(), ax.get_yaxis_transform()), ha="left", va='center', color=line.get_color())
print(ax.get_xaxis_transform())
I found out that this piece of code is incompatible with app.powerbi.com report view.
Not sure if it's powerbi web view bug or not, because power bi desktop app can display everything correctly as intended.
Hi @zawlynn ,
As mentioned in https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.xticks.html?highlight=xticks#matplotlib.... . The first parameter for plt.xtricks should be the list of xtick locations. Please check for it.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
Hello,
As I have explained earlier, xticks works with report web view. Therefore I don't think the error comes from xticks.
plt.xticks(dataset.Year_month, dataset.Year_month, rotation=45, ha='right')
The issue here is power bi web view is having issue with seaborn module.
Hi @zawlynn ,
Reduce your data volume and see whether the same issue occurs or not.
You can try this one -
import matplotlib.pyplot as plt
import pandas as pd
import seaborn as sns
dataset['Year_month'] = pd.to_datetime(dataset['Year_month'], errors='coerce')
dataset['Budget'] = pd.to_numeric(dataset['Budget'], errors='coerce')
dataset['Actual'] = pd.to_numeric(dataset['Actual'], errors='coerce')
fig, ax = plt.subplots()
sns.lineplot(ax=ax, data=dataset, x='Year_month', y='Budget', hue='office', legend=None)
sns.lineplot(ax=ax, data=dataset, x='Year_month', y='Actual', hue='office', legend=None, linestyle='--')
cust_anno = ['line1','line2','line3','line4','line5','line6','line7','line8','line9','line10','line11','line12']
for line, name in zip(ax.lines, cust_anno):
y = line.get_ydata()
x = line.get_xdata()
if len(y) > 0:
ax.annotate(name, xy=(x[-1], y[-1]), xycoords='data', ha="left", va='center', color=line.get_color())
plt.xticks(dataset['Year_month'], dataset['Year_month'].dt.strftime('%Y-%m'), rotation=45, ha='right')
plt.tight_layout(pad=0, w_pad=0, h_pad=0)
plt.show()
I hope it will be helpful.
Thanks,
Sai Teja
Hi @zawlynn ,
Would you please add a index column or continous value column in your dataset? Then use it as the first parameter in the plt.xticks.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
does it repro with local python IDE like jupiter notebook etc?
I see you mention:
Not sure if it's powerbi web view bug or not, because power bi desktop app can display everything correctly as intended.
Then it seems related to the specific library version PowerBI used in web. Learn which Python packages are supported - Power BI | Microsoft Docs
With some search:
All of these does not help?
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
57 | |
30 | |
24 | |
23 | |
20 |
User | Count |
---|---|
57 | |
37 | |
23 | |
22 | |
20 |