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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
akennedy
Frequent Visitor

Power BI and self-reference in R

Hello,

I'm very new to PowerBI, so forgive me if this is a simple question. Exactly how does self reference in R effect the results of a Power BI query? If I were to run a very simple script, say

 

set.seed(50)
x = rnorm(n = 100, mean = 0, sd = 1)
x = as.data.frame(x)

I get a table, named "X", with a single column, named "get(x)", and a single row, "x"

 

But when I run a slightly more complicated script

 

set.seed(50)
x = rnorm(n = 100, mean = 0, sd = 1)
y = as.data.frame(x)

I get a table, named "y", with a single column, named "x", and 100 rows from a normal distribution.

 

In R, the results are the same, except for the name of the variable. Both scripts result in a data.frame with one column and 100 rows. In PowerBI, I have no idea what's going on. Is it getting stuck on have a data.frame with the exact same name as what it wants to use as the column name?

1 ACCEPTED SOLUTION
v-caliao-msft
Microsoft Employee
Microsoft Employee

@akennedy,

 

I have tested this R script in R Studio and Power BI desktop. I get the same result as yours. The issue could be caused the get data mechanism in Power BI. The acceptable thing is that you can use your second script to get your expected dataset currently. I will report this issue internally.

set.seed(50)
x = rnorm(n = 100, mean = 0, sd = 1)
y = as.data.frame(x)

 

 

Regards,

Charlie Liao

View solution in original post

2 REPLIES 2
akennedy
Frequent Visitor

That must be it. If the column returned in Power BI were "get('x')" instead of "get(x)", it would return the 100 row data.frame since get() searches for objects by name. The get() documentation page even mentions : "For get, an object name (given as a character string)."
v-caliao-msft
Microsoft Employee
Microsoft Employee

@akennedy,

 

I have tested this R script in R Studio and Power BI desktop. I get the same result as yours. The issue could be caused the get data mechanism in Power BI. The acceptable thing is that you can use your second script to get your expected dataset currently. I will report this issue internally.

set.seed(50)
x = rnorm(n = 100, mean = 0, sd = 1)
y = as.data.frame(x)

 

 

Regards,

Charlie Liao

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.