Forum Discussion
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?
- Anonymous2 years ago
Hi Anonymous
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.
2 Replies
- AnonymousNot applicable
Hi Anonymous
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.
- AnonymousNot applicable
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 🙂