Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I would like to access the Power BI data model/cube (not sure if this is the right term). I would like to access the underlying data model, so that I get access to the measures and calculated models. We have Power BI Premium P1.
I can already do this when we use the analyze in excel option through .odc file. I have also accessed this data in R but I cannot make it work in the Power BI when I use the R Script option.
The script below works in the R Studio. It would be great if I can make this work in the Power BI because that would make accessing other reports easy and avoid duplication of work. The script below is from Microsoft. https://docs.microsoft.com/en-us/machine-learning-server/r-reference/olapr/olapr
library(olapR)
# Connect to a local SSAS default instance and the Analysis Services Tutorial database.
# For named instances, use server-name\\instancename, escaping the instance name delimiter.
# For databases containing multiple cubes, use the cube= parameter to specify which one to use.
cnnstr <- "Provider=MSOLAP;Integrated Security=ClaimsToken;
Persist Security Info=True;
Initial Catalog=*********************************;
Data Source=pbiazure://api.powerbi.com;MDX Compatibility=1;Safety Options=2;
MDX Missing Member Mode=Error;
Identity Provider=https://***************************,
https://******************,
**************************************;Update Isolation Level=2"
olapCnn <- OlapConnection(cnnstr)
# Approach 1 - build the mdx query in R
qry <- Query()
cube(qry) <- "Model"
#columns(qry) <- c("[Measures].[Internet Sales Count]", "[Measures].[Internet Sales-Sales Amount]")
#rows(qry) <- c("[Product].[Product Line].[Product Line].MEMBERS")
#slicers(qry) <- c("[Sales Territory].[Sales Territory Country].[Australia]")
#result1 <- executeMD(olapCnn, qry)
# Approach 2 - Submit a fully formed MDX query
mdx <- "SELECT { [Measures].[my_measure] } ON 0 ,
{ [Table].[dim].AllMembers } ON 1
FROM [Model] "
result2 <- execute2D(olapCnn, mdx)
The error I get when I run this script in Power BI is in the second image
Hi darshan,
I am not familiar with R , I will discuss this with other engineers, I will inform you as soon as I get it. So if possible, could you please inform me the detailed error information?
Best Regards,
Zoe Zhi
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi Zoe,
Thank you for the reply. I had attached an image but dont see it now.
Anyway please see the image below
1st image is the input
2nd image is the error
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!
| User | Count |
|---|---|
| 41 | |
| 39 | |
| 37 | |
| 29 | |
| 24 |
| User | Count |
|---|---|
| 118 | |
| 98 | |
| 70 | |
| 69 | |
| 65 |