5

In my Power BI dashboard, I created a Python Script that accesses an API and generates a Pandas data frame.

It works fine, but how can I edit the Python code?

I thought it would be something simple, but I can't really find how to find it in the interface. If I send the .pbix file to someone, they will receive an alert that a Python script is executing and display the code nicely formatted.

I can find the code if I go to "Model Exhibition -> Edit query -> Advanced Editor" (I'm translating the options from another language, they can be somewhat different). I is a M language code and the Python script is displayed as a long line as the image below:

How python code is displayed in power bi

I believe it is possible to open a text box to edit the Python script, but can't really find it.

Davide Bacci
  • 16,647
  • 3
  • 10
  • 36
neves
  • 33,186
  • 27
  • 159
  • 192

2 Answers2

2

In Power Query you should be able to click on the ribbon to insert Python code as below.

enter image description here

If the script is existing, then click the little cog icon to the right of the step in APPLIED STEPS as below:

enter image description here

Davide Bacci
  • 16,647
  • 3
  • 10
  • 36
  • But I don't have Power Query installed. Just Power BI Desktop – neves May 26 '23 at 19:14
  • Power Query is part of Power BI. In Power BI, on the Home ribbon, click Transform Data to open Power Query – Davide Bacci May 26 '23 at 19:16
  • You were already in PowerQuery when you were looking at the advanced editor code :) – Luke_0 May 26 '23 at 19:20
  • I found it. In the Brazilian Portuguese translation "Run Python Script" becomes just "Fonte" (source in Portuguese). Really hard to find. – neves May 26 '23 at 19:37
0

In powerBI when you do any manipulation to the data, be it dataframe creation, it is called as data transformation.

If at anytime you want to alter the steps you have used for a particulat table.

You need to click on transform tab on the top 2nd position from left hand side.

then click on applied steps and go to the step you want to alter.

Prem Prakash
  • 90
  • 1
  • 10