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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

edit graph

I want to edit graph from  pic1 to pic2 

guide ma about it please.

 

 

adamasmay_1-1615440095706.png

Pic 1

 

adamasmay_2-1615440119492.png

Pic2

 

21 REPLIES 21
v-kkf-msft
Community Support
Community Support

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()

image.png

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.

Anonymous
Not applicable

@v-kkf-msft  Please send file pbix to me.

Anonymous
Not applicable

@v-kkf-msft  It not show.

adamasmay_0-1615966649734.png

 

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.

image.png

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.

image.png

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.

Anonymous
Not applicable

@v-kkf-msft  If I have 2 value as below.

 

How to edit code python ?

adamasmay_0-1615977367511.png

 

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()

 

image.png

This is my PBIX file.

https://microsoftapc-my.sharepoint.com/:u:/g/personal/v-lazhang_microsoft_com/Ebu-MHhmMUdMp_6zF1bJTUwBMEsiOJhtWOR3V1PLffHEOA?e=FSUTuX

 

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.

Anonymous
Not applicable

@v-kkf-msft It show error as below.

 

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

Anonymous
Not applicable

@v-kkf-msft Sorry, I can't send PBIX to you because data have internal.

data.JPG

 

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.

Anonymous
Not applicable

@v-kkf-msft   It show can't display this visual.

adamasmay_0-1616122684645.png

 

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)

adamasmay_1-1616123469719.png

 

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

Anonymous
Not applicable

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

image.png

image.png

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.

Anonymous
Not applicable

@v-kkf-msft   I want to show in graph .

But order by sort.

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
    )   

image.png

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.

Anonymous
Not applicable

@v-kkf-msft  from your dax in yellow highlight as below.

adamasmay_1-1616468093491.png

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

Anonymous
Not applicable

@v-kkf-msft   It show can't display the visual same (python)

adamasmay_0-1616495730333.png

 

 

 

my data have 120 rows and 35 columns.

 

Help me please.

 

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors