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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
tdoolittle
Frequent Visitor

Retrieve M Code from Semantic Model Queries

Hi,

 

Is there a way, (and if so, what is the simplest), to retrieve the M code statement from a semantic model published to a PBI Service workspace? I'm specifically looking for what you would normally see in the 'Advanced Editor' section of Power Query Editor without having to download the PBIX and open it in Power BI Desktop. The ideal solution allows it to be searchable either by semantic model (all queries involved with a single model) or by workspace (all queries involved with all semantic models within a workspace).

 

Note that we have not yet implemented deployment pipelines for PBIT files which should theoretically allow me to do this, but I can't seem to find any REST API or DAX INFO function that returns this data. We do have a Premium SKU.

 

Thanks!

2 REPLIES 2
collinq
Super User
Super User

HI @tdoolittle ,

 

I do not think that there is any way to do that in the Service.  But, in the Desktop, you don't have to look at each and every query individually to get the M code.  You can go to File- About and then select "copy"  next to "Copy session diagnostics to clipboard" and that will give you all of the queries in the entire file.




Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!
Private message me for consulting or training needs.




Interesting workaround, thanks! Unfortunately still requires each PBIX to be downloaded individually. As you can imagine, questions like "how does this table schema change affect PBI in general" could only be answered with that approach. Your solution certainly saves a bit of time, but it's still a massive manual effort.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Kudoed Authors