I have a file with 21,076 rows and 2 columns: “id” and “text”. I am trying to use R scripts to connect to Azure Cognitive Services API and apply Language detection to the “text” column. When I run my script in R Studio it works fine on the 21,076 rows (Due to limitations of the API Im sending chunks of 1,000 messages and then appending the results in R to an output dataframe to be used in PowerBI).
However, when I use PowerBI R scripts, the query seems to run the R script multiple times (Im saving in a .csv each time the code calls the API). I can see internally that the R code is sucessfully generating the output data frame of 21,076 rows but strangly the query is running the script AGAIN, this second time generates 9,000 rows (the first 9 chunks I’m sending to Azure).
Is it Power Query running my R script more than once? why?
7 Comments
- v-haibl-msft
Microsoft Employee
- Vicky_Song
Impactful Individual
Status changed:NewtoNeeds Info - jrecasens
Advocate I
Attached you can find the files:
https://1drv.ms/f/s!ApFP03_iPLLTg44qzx0JTucsro8UnwYou need to change two things: the folder parameter in the .pbix file and also update your API key in the R code. You can create a "Text Analytics API" key here:
https://azure.microsoft.com/en-us/try/cognitive-services/?api=text-analytics
The .pbix has a query that references the R code (code.R file). The resulting dataset (output.txt) should have 9,181 rows but in PowerBI, chunks of data are sent multiple times, as shown in the log.txt output.To test it in R Studio just un-comment the first lines of code.
- jrecasens
Advocate I
Hello, do you have news regarding this issue? thank you.
- clued__init__Frequent Visitor
Did you ever find a solution for this? I just posted a similar issue in the community forum:
Query Containing R Script Algorithm is Evaluated Twice on Refresh
- jrecasens
Advocate I
I did NOT find a solution. I have updated the link (with my example) if its helps.
- clued__init__Frequent Visitor
The consistencies in our methods are that we both use a parameter query, and we both define a custom table other than the default "dataset" in our R.exectue() call. See my forum post for a simple reproduction of our issue.