The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now
Hi,
When I tryto run this simple python script in power bi it throws this error " the preview for section 1/query1/source doesn't exist"
Solved! Go to Solution.
Hi @ahmedidris ,
I am asssuming that you are following the below link to run this pythin script:
https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts
I tried doing same and I can successfully run the script in python editor:
Also, make sure your Python home directory path is defined correctly in Power BI Desktop:
Thanks,
Pragati
Hello everyone, Have you managed to solve your issue?
I face exactly the same error message "the preview for section 1/query1/source doesn't exist" when using a R script:
R script works in RStudio and other Rscript works in the same pbix (therefore link to R work well).
Here is the R script reading from Humanitarian Data Exchange package rhdx:
library(rhdx)
library(tidyverse)
library(stringr)
library(dplyr)
dataset<-search_datasets("INFORM Country Risk Profiles", rows = 3)
ds<-get_resources(nth(dataset,1))
nb_ds<-length(ds)
Hazards<- vector("list", length = nb_ds)
var_interes<-c("COUNTRY","Iso3","Physical exposure to earthquake","Physical exposure to flood","Physical exposure to tsunami","Physical exposure to tropical cyclone","Droughts probability and historical impact","Physical exposure to epidemics","INFORM Natural Hazard","GCRI Internal Conflict Score","Current Highly Violent Conflict Intensity Score","INFORM Human Hazard")
for (i in 1:nb_ds){
Hazards[[i]]=read_resource(ds[i][[1]],sheet="Hazard & Exposure")
for (j in names(Hazards[[i]])){
if (!(j %in% var_interes)){
Hazards[[i]]<-Hazards[[i]][-c(which( colnames(Hazards[[i]])==j ))]
}
}
Hazards[[i]]$name_ds<-ds[i][[1]][["data"]][["name"]]
Hazards[[i]]$desc_ds<-ds[i][[1]][["data"]][["description"]]
Hazards[[i]]$format_ds<-ds[i][[1]][["data"]][["format"]]
Hazards[[i]]$Index<-i
}
INFORM_RISK_Hazard<-do.call(bind_rows,Hazards)
INFORM_RISK_Hazard
@ahmedidris , refer if these can help
Python
https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts
https://en.blog.businessdecision.com/how-to-use-the-python-integrator-in-powerbi/
https://towardsdatascience.com/using-python-in-power-bi-ee95a6b71443
https://powerbi.microsoft.com/en-us/blog/python-visualizations-in-power-bi-service/
Hi @ahmedidris ,
Can you show the M code?
I tried blank query, it worked well
Hi @ahmedidris ,
I am asssuming that you are following the below link to run this pythin script:
https://docs.microsoft.com/en-us/power-bi/connect-data/desktop-python-scripts
I tried doing same and I can successfully run the script in python editor:
Also, make sure your Python home directory path is defined correctly in Power BI Desktop:
Thanks,
Pragati
Hi Pragati,
I tried the steps mentioned by you but still I am getting the same error. Is there anything else which needs to be done
Hi, I also faced this error when trying to connect my python script to power bi, while the python script works well by itself. I fixed the connection error by simplifying my script, e.g. reducing the number of function within a function, avoiding complex calculations. I just keep trial and error until my script is 'simple' enough for power bi to process it.
Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.
User | Count |
---|---|
158 | |
109 | |
96 | |
83 | |
75 |
User | Count |
---|---|
154 | |
137 | |
131 | |
81 | |
62 |