Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Works in the query editor, but encounter error when I close and apply:
Failed to save modifications to the server. Error returned: 'Expression in partition 'n/a' in table 'n/a' references unknown variable or function 'Python.Execute'.'.
Python version 3.8.2
Excel file
Fibonacci |
0 |
1 |
1 |
2 |
3 |
Python Script:
dataset.loc[0,'Fibonacci Python'] = 0 dataset.loc[1,'Fibonacci Python'] = 1 for i in range(2, len(dataset)): dataset.loc[i,'Fibonacci Python'] = dataset.loc[i-1,'Fibonacci Python'] + dataset.loc[i-2,'Fibonacci Python']
Fibonacci | Fibonacci Python |
0 | 0 |
1 | 1 |
1 | 1 |
2 | 2 |
3 | 3 |
let
Source = Excel.Workbook(File.Contents("****.xlsx"), null, true),
Fibonacci_Table = Source{[Item="Fibonacci",Kind="Table"]}[Data],
#"Changed Type" = Table.TransformColumnTypes(Fibonacci_Table,{{"Fibonacci", Int64.Type}}),
#"Run Python script" = Python.Execute("# 'dataset' holds the input data for this script#(lf)dataset.loc[0,'Fibonacci Python'] = 0#(lf)dataset.loc[1,'Fibonacci Python'] = 1#(lf)#(lf)for i in range(2, len(dataset)):#(lf) dataset.loc[i,'Fibonacci Python'] = dataset.loc[i-1,'Fibonacci Python'] + dataset.loc[i-2,'Fibonacci Python']",[dataset=#"Changed Type"]),
dataset = #"Run Python script"{[Name="dataset"]}[Value],
#"Changed Type1" = Table.TransformColumnTypes(dataset,{{"Fibonacci", Int64.Type}, {"Fibonacci Python", Int64.Type}})
in
#"Changed Type1"
Solved! Go to Solution.
Hi, @VO
With your provided information, I managed to do it with no error.
I'd like to suggest you go to Option > Preview features and uncheck Store dataset using enhanced metadata format. Then you need to restart Power BI to see if it works.
For further information, you may refer the following links.
Failed to save modifications to the server. function Python.Execute
Using enhanced dataset metadata (preview)
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, @VO
I wonder if you have install required Python packages and enable Python scripting in Power BI. For further information, I'd like to suggest you refer the following document.
Run Python scripts in Power BI Desktop
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Allan,
I installed pandas, matplotlib and NumPy. Python scripting is enabled. It actually works in the query editor and gives the expected output. However, it gives an error when I am trying to close and apply the changes.
Hi, @VO
With your provided information, I managed to do it with no error.
I'd like to suggest you go to Option > Preview features and uncheck Store dataset using enhanced metadata format. Then you need to restart Power BI to see if it works.
For further information, you may refer the following links.
Failed to save modifications to the server. function Python.Execute
Using enhanced dataset metadata (preview)
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @v-alq-msft
Did it all over again, it worked. Thank you.
"Enabling the enhanced dataset metadata feature results in an irreversible upgrade to reports. Any Power BI reports loaded or created with Power BI Desktop, once the enhanced dataset metadata enabled, are irreversibly converted to the enhanced dataset metadat format."
Hi @v-alq-msft
Unfortunately, despite unchecking & restarting. It didn't work. Same error. Did you mange to close and apply the changes (I have the same output you have shared in the query editor)? Are running it on Python version 3.8.2? Thank for the other suggestions, I will explore them.
Error on Close & Aply
Failed to save modifications to the server. Error returned: 'Expression in partition 'n/a' in table 'n/a' references unknown variable or function 'Python.Execute'.'.
Query Editor
User | Count |
---|---|
121 | |
76 | |
63 | |
51 | |
50 |
User | Count |
---|---|
175 | |
125 | |
60 | |
60 | |
58 |