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
Anonymous
Not applicable

how to use a parameter to upload sas7bdat file in Power BI via R

I try to upload a sas7bdat file in Power BI via R code. It works fine with this code:

 

require(sas7bdat)

input<-read.sas7bdat("C:/Users/jansens/Desktop/filename.sas7bdat")

 

Now I would like tot put the filepath into a parameter, in order to be able to move a whole group of sas7bdat files to another folder and still be able to use my PowerBI datamodel, simply by changing the value of the parameter.

So I made a parameter with the name path and the value  C:/Users/jansens/Desktop/, which I then use in the R script:

 

require(sas7bdat)

input<-read.sas7bdat(""&path&"filename.sas7bdat")

 

But now I get the following error:  object 'path' not found.

 

Any idea how to make this work?

1 REPLY 1
v-yingjl
Community Support
Community Support

Hi @Anonymous ,

Maybe you can try like this:

"&""""& path & "filename.sas7bdat"

Refer these artilces:

  1. Execute R Script with Power BI Parameter 
  2. Using Parameters in an R Script for a Power BI Query 

 

Best Regards,
Yingjie Li

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

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.