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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Brian_M
Responsive Resident
Responsive Resident

Why does Sys.getenv("USERNAME") return empty result in Power BI?

Can someone explain why this R script is not allowed to return environment information in Power BI?

 

If I run it in RGui then I receive the Windows username as expected

 

let
    source = R.Execute("Sys.getenv(""USERNAME"")")
in
    source

 

 

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @Brian_M,

 

I can reproduce your issue, even if I test "OS", "Path" but I still get the empty result. I also try to use "get data" from R script and get the same result.

 

Capture.PNG

 

Can you directly use R script to get the environment variables? If you can, it may means power bi not allow use R script to get environment information.

 

In addition, you can take a look at below article about using R script:

Running R Scripts in Power BI Desktop 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @Brian_M,

 

I can reproduce your issue, even if I test "OS", "Path" but I still get the empty result. I also try to use "get data" from R script and get the same result.

 

Capture.PNG

 

Can you directly use R script to get the environment variables? If you can, it may means power bi not allow use R script to get environment information.

 

In addition, you can take a look at below article about using R script:

Running R Scripts in Power BI Desktop 

 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

Thanks for the link.  Yes, it works when used directly in R so it appears that Power BI is sandboxed in some way that it can't read that type of information.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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