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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
jd_87
Frequent Visitor

R scripting visualizations using DAX measures - is it possible?

I'm using the R script editor to make some custom visualizations in a PBI report and I'm wondering if it's possible to add PBI measures to the dataframe that you make in the R script - i.e., so my resulting data frame would be one row long and every column would be the value of a different DAX-calculated measure. I've tried to do this with a simple measure (a proportion) but when I display the value on my R visualization it appears to be gibberish numbers.

 

Are measures something that you can incorporate into this kind of thing, or would you need to calculate them again within the R script?

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

Hi @jd_87 

 Only data frames are imported to the R, remember to represent the data you want to import to Power BI in a data frame,  you need to calculate them again within R script, the language of measure cannot support in R script., you can refer to the following link.

https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-r-scripts#prepare-an-r-script

 

Best Regards!

Yolo Zhu

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

 

 

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @jd_87 

 Only data frames are imported to the R, remember to represent the data you want to import to Power BI in a data frame,  you need to calculate them again within R script, the language of measure cannot support in R script., you can refer to the following link.

https://learn.microsoft.com/en-us/power-bi/connect-data/desktop-r-scripts#prepare-an-r-script

 

Best Regards!

Yolo Zhu

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

 

 

So, I've given this another shot, and it actually seems like you CAN work with measures in R - at least as long as the dataframe you're making in R is just a collection of measures.

 

For instance, if I add a series of PBI measures to my R visual, I can refer to them each individually (e.g., dataset[1,1], dataset[1,2], etc.), which is what I want. I'm not sure why the numbers weren't displaying correctly when I tried this the first time, but it seems to be working fine now 🙂 

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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