Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
eliasrs
New Member

R Script error in Power BI but not on RStudio

Hello all.

Im trying to create an R Visual to plot a control chart within Power BI.

The script has been validated and runs on Rstudio (launched from power BI) but when I run it in Power BI I get the following error.

 

Error Message:
R script error.
Error in data.frame(TestDate, Meas) : object 'TestDate' not found
Execution halted

 

Looking though the forum found similar questions with no solution. Someone suggested to change R version, I have tried with 3.3.1 and 3.6.1 so far with exact samne results.

 

The script I'm trying to run is as follows.

 

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
dataset <- data.frame(TestDate, Meas)
dataset <- unique(dataset)
# Paste or type your script code here:
library(qcc)
newdata <- dataset[order(dataset$TestDate),]
x <- c(newdata$TestDate)
s <- c(newdata$Meas)
qcc(s, type="xbar.one",nsigmas=3, labels=x)

 

 

Any ideas on how to solve this?

 

Regards

 

1 ACCEPTED SOLUTION
webportal
Impactful Individual
Impactful Individual

Hi,

The dataset dataframe is created automatically by Power BI, thus you don't need the following line of code:

dataset <- data.frame(TestDate, Meas)

If you can share the data or the pbix, perhaps I could be more helpful.

View solution in original post

7 REPLIES 7
webportal
Impactful Individual
Impactful Individual

Can you try this code:

library(qcc)
qcc(dataset["Meas"], type="xbar.one",nsigmas=3, labels=dataset["TestDate"])

Thanks for the susggestion but it didn't work

It actualy throws the error on the following line

dataset <- data.frame(TestDate, Meas) can't find object TestDate.
So, the dataset creation is not working.
 
I tried to adapat to DAX format (Q325[TestDate]) but id did not work.
 
 

 

 

webportal
Impactful Individual
Impactful Individual

Hi,

The dataset dataframe is created automatically by Power BI, thus you don't need the following line of code:

dataset <- data.frame(TestDate, Meas)

If you can share the data or the pbix, perhaps I could be more helpful.

Well, just commented the extra line idicated and it worked! this was the end script.

 

# The following code to create a dataframe and remove duplicated rows is always executed and acts as a preamble for your script:
dataset <- unique(dataset)
library(qcc)
newdata <- dataset[order(dataset$TestDate),]
x <- c(newdata$TestDate)
s <- c(newdata$Meas)
qcc(s, type="xbar.one",nsigmas=3, labels=x)
 
Thanks a lot.

 

webportal
Impactful Individual
Impactful Individual

Have you added TestDate field to the values area of the R visual you're trying to create?

Yes, TestDate and Meas are added to Value field.

 

eliasrs_0-1595879373518.png

 

Thanks


In Rstudio runs fine.

 

eliasrs_0-1595879716098.png

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors