Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi everyone,
I have a question concerning the use of R to transform data in Power BI.
I am working on this table and trying to replace the first column data.
I have trouble understanding how does R code can really interact with data, and I am a beginner in R. This might be why I get this error :
I wrote this script (trying, as a test, to replace all values of the first column by 1) and when I run it, the data seems to be empty :
ctr <- 0
for (day in dataset[,1]) {
ctr <- ctr + 1
dataset[,1][ctr] <- 1
}
I thought someone may have a solution.
Thanks,
Baptiste
Solved! Go to Solution.
Hi @didierjoc,
In your R scrip, there are no result, so it returns empty table. I try to reproduce you scenario and get expected result.
The following is sample data, I replace the first column data to 1.
In the Power Query Editor, click the “Run R Scripts”, type the following script and click OK.
ctr <- 0for (day in dataset[,1]) {ctr <- ctr + 1 dataset[,1][ctr] <- 1}output<-dataset
Finally, click Apply&Close, you will get the expected result as the following screenshot.
If you have any other issue, please feel free to ask.
Best Regards,
Angelia
Hi @didierjoc,
In your R scrip, there are no result, so it returns empty table. I try to reproduce you scenario and get expected result.
The following is sample data, I replace the first column data to 1.
In the Power Query Editor, click the “Run R Scripts”, type the following script and click OK.
ctr <- 0for (day in dataset[,1]) {ctr <- ctr + 1 dataset[,1][ctr] <- 1}output<-dataset
Finally, click Apply&Close, you will get the expected result as the following screenshot.
If you have any other issue, please feel free to ask.
Best Regards,
Angelia
Hi Angelia,
It works indeed, I didn't know I had to do so !
Thanks a lot !
Didier
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
110 | |
96 | |
77 | |
63 | |
55 |
User | Count |
---|---|
143 | |
109 | |
89 | |
84 | |
66 |