0

I am new to Power BI and have recently been exploring its potential use as a data visualization tool. I currently add my data through Get Data -> "R Script" where I use read.csv and the dplyr package to import and sort through the messy data. I currently haven't found a way to edit the import scripts so any new changes I make to the script result in me having to re-import the data and reconnecting all the app links.

My potential new approach is to import the data into Power BI with read.csv and modifying the contents via Transform Data -> Transform -> R Script. My issue is that when I run the following script Power BI's output is an empty table:

i.e:# 'dataset' holds the input data for this script

library(dplyr)

dataset <- dataset %>%
select(2,3,4) %>%
rename(First= A) %>%
rename(Last= B) %>%
rename(Extra= C)

Said script runs on RStudio, any suggestions?

k3r0
  • 357
  • 1
  • 10
  • Without the dataset it is very difficult to help you out. Visit [this](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example). – UseR10085 Jun 15 '20 at 06:00

1 Answers1

1

Your second approach sounds about right which is to load data first in Power BI and then transform it in R.

Load the output of your R script to a new variable which should fix the problem. Updated script is below:

library(dplyr)

output <- dataset %>%
select(2,3,4) %>%
rename(First= A) %>%
rename(Last= B) %>%
rename(Extra= C)
vn1gam
  • 128
  • 1
  • 8
  • Changing the data output name solved the issue! I thought it had to retain the same name in order to prevent another data frame from being created. – k3r0 Jun 15 '20 at 06:19
  • Power Query creates a new table as an outcome of each transformation step. You can observe this by clicking on "Advanced Editor" when in Power Query - a new table name is assigned to output of each transformation step. – vn1gam Jun 15 '20 at 06:29