Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
I want to edit graph from pic1 to pic2
guide ma about it please.
Pic 1
Pic2
Hi @Anonymous ,
You can do it by writing python scripts. First, please refer to this document to install Python and connect to the data source. Run Python scripts in Power BI Desktop
Then use the following script in the Python visual.
import numpy as np
import matplotlib.pyplot as plt
y = dataset.ID
x = dataset.value
# Default Settings
b = plt.barh(y, x)
for rect in b:
w = rect.get_width()
plt.text(w, rect.get_y()+rect.get_height()/2, '{:.0%}'.format(w), ha='left', va='center',fontsize=20)
plt.xticks([0.05, 0.5,0.9, 1],['$on process$', '$continue$', '$On the way$','$Completed$'])
plt.grid(axis="x", which="major",linestyle='-.')
plt.title('custom')
plt.xlabel('xlabel name')
plt.ylabel('ylabel name')
plt.show()
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
This is my PBIX file.
Hi @Anonymous ,
You must install Python on your computer to execute these scripts. Because desktop does not have built-in Python.
Run Python scripts in Power BI Desktop
If you are opening my PBIX file, when you see the prompt in the figure below, you need to click Enable to load it.
If you want to apply it in your PBIX file, you need to modify the ID and value to the fields in the table imported.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
Use the following script in the Python visual.
import numpy as np
import matplotlib.pyplot as plt
y = dataset.ID
x1 = dataset.value1
x2 = dataset.value2
# Default Settings
b=plt.barh(y, x1,align="center",color="#66c2a5",label="value1")
b2=plt.barh(y, x2,align="center",left=x1,color="#8da0cb",label="value2")
for rect in b:
w = rect.get_width()
plt.text(w-0.05, rect.get_y()+rect.get_height()/2, '{:.0%}'.format(w), ha='left', va='center',fontsize=20)
plt.xticks([0.05, 0.5,0.9, 1],['$on process$', '$continue$', '$On the way$','$Completed$'])
plt.grid(axis="x", which="major",linestyle='-.')
plt.title('custom')
plt.xlabel('xlabel name')
plt.ylabel('ylabel name')
plt.legend()
plt.show()
This is my PBIX file.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
There are many situations that can cause this error, which may be a version problem or a path problem. Maybe you can share your PBIX file, that can help us solve it faster.
Best Regards,
Winniz
@v-kkf-msft Sorry, I can't send PBIX to you because data have internal.
import numpy as np
import matplotlib.pyplot as plt
dataset = pandas.DataFrame(% Developing(In month), % Developing(Last Month), code and name process)
y = dataset.code and name process
x1 = dataset.% Developing(Last Month)
x2 = dataset.% Developing(In month)
b=plt.barh(y, x1,align="center",color="#66c2a5",label="% Developing(Last Month)")
b2=plt.barh(y, x2,align="center",left=x1,color="#8da0cb",label="% Developing(In month)")
for rect in b:
w = rect.get_width()
plt.text(w-0.05, rect.get_y()+rect.get_height()/2, '{:.0%}'.format(w), ha='left', va='center',fontsize=20)
plt.xticks([0.05, 0.5,0.9, 1],['$on process$', '$continue$', '$On the way$','$Completed$'])
plt.grid(axis="x", which="major",linestyle='-.')
plt.title('custom')
plt.xlabel('xlabel name')
plt.ylabel('ylabel name')
plt.legend()
plt.show()
Guide me for solve it please.
Hi @Anonymous ,
This error occurs because these column names cannot be correctly recognized by Python. The simple solution is to modify the column names: code_and_name_process, Developing_In_Month, Developing_Last_Month.
Then remove the python visual and recreate it, because the Python script only uses the original column name.
import numpy as np
import matplotlib.pyplot as plt
y = dataset.code_and_name_process
x1 = dataset.Developing_Last_Month
x2 = dataset.Developing_In_Month
b=plt.barh(y, x1,align="center",color="#66c2a5",label="Developing_Last_Month")
b2=plt.barh(y, x2,align="center",left=x1,color="#8da0cb",label="Developing_In_Month")
for rect in b:
w = rect.get_width()
plt.text(w-0.05, rect.get_y()+rect.get_height()/2, '{:.0%}'.format(w), ha='left', va='center',fontsize=20)
plt.xticks([0.05, 0.5,0.9, 1],['$on process$', '$continue$', '$On the way$','$Completed$'])
plt.grid(axis="x", which="major",linestyle='-.')
plt.title('custom')
plt.xlabel('xlabel name')
plt.ylabel('ylabel name')
plt.legend()
plt.show()
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-kkf-msft It show can't display this visual.
Table Append1 from 2021(2) and Before 2021 as below.
In append1 I add column code and name process (combine value column class and code together)
Hi @Anonymous ,
This is a known limitation:
Python visuals in Power BI Desktop have a few limitations:
• Data size limitations. Data used by the Python visual for plotting is limited to 150,000 rows. If more than 150,000 rows are selected, only the top 150,000 rows are used and a message is displayed on the image. Additionally, the input data has a limit of 250 MB.
• Resolution. All Python visuals are displayed at 72 DPI.
• Calculation time limitation. If a Python visual calculation exceeds five minutes the execution times out which results in an error.
https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-visuals#known-limitations
There is no good solution. My suggestion is to create a separate table to store the summarized values (90%, 5%, 80%, 10%), and use the data in this table to create Python visual. Reduce the calculation time in power BI, but it no longer changes dynamically.
Best Regards,
Winniz
@v-kkf-msft Kindly find excel attached as below. File Excel (Input)
but I want add new requirement as below.
1. sort status by on the way , deploy , Get requirement , Compleated and blank
2. If status = on the way sort by lowerst to highest
Guide me about it please.
Thank you for your help me.
Hi @Anonymous ,
Create a calculate column:
Sort Order =
var a =
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
'Table'[Developing_In_month] <= EARLIER('Table'[Developing_In_month])
&&'Table'[Status_2021] = "on the way"
)
)
return
SWITCH(
'Table'[Status_2021],
"on the way",1+0.1*a,
"Deploy", 2,
"Get requirement", 3,
"Completed", 4,
5
)
Select the Code column, and select the Sort Order column in the Sort by column drop-down list.
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Anonymous ,
First create a calculated column Sort_Order. Then create Python visual objects.
Sort_Order =
var a =
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
'Table'[Developing_In_month] <= EARLIER('Table'[Developing_In_month])
&&'Table'[Status_2021] = "on the way"
)
)
return
SWITCH(
'Table'[Status_2021],
"on the way",1+0.1*a,
"Deploy", 2,
"Get requirement", 3,
"Completed", 4,
5
)
import numpy as np
import matplotlib.pyplot as plt
dataset.columns = ["Code","Developing_In_month", "Developing_Last_Month", "Sort_Order"]
dataset.sort_values(by = 'Sort_Order',ascending = False,inplace = True)
y = dataset.Code
x1 = dataset.Developing_Last_Month
x2 = dataset.Developing_In_month
b=plt.barh(y, x1,align="center",color="#66c2a5",label="Developing_Last_Month")
b2=plt.barh(y, x2,align="center",left=x1,color="#8da0cb",label="Developing_In_Month")
for rect in b:
w = rect.get_width()
plt.text(w-0.05, rect.get_y()+rect.get_height()/2, '{:.0%}'.format(w), ha='left', va='center',fontsize=20)
plt.xticks([0.05, 0.5,0.9, 1],['$on process$', '$continue$', '$On the way$','$Completed$'])
plt.grid(axis="x", which="major",linestyle='-.')
plt.title('custom')
plt.xlabel('xlabel name')
plt.ylabel('ylabel name')
plt.legend()
plt.show()
If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@v-kkf-msft from your dax in yellow highlight as below.
I want to sort status on the way by sum value Developing_in_Month and Developing_Last_Month.
Please guide me.
Hi @Anonymous ,
Modify calculated column Sort_Order:
Sort_Order =
var a =
CALCULATE(
COUNTROWS('Table'),
FILTER(
ALL('Table'),
('Table'[Developing_In_month]+'Table'[Developing_Last_Month]) <= EARLIER('Table'[Developing_In_month]) + EARLIER('Table'[Developing_Last_Month])
&&'Table'[Status_2021] = "on the way"
)
)
return
SWITCH(
'Table'[Status_2021],
"on the way",1+0.1*a,
"Deploy", 2,
"Get requirement", 3,
"Completed", 4,
5
)
Best Regards,
Winniz
@v-kkf-msft It show can't display the visual same (python)
my data have 120 rows and 35 columns.
Help me please.