cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
mariussve1
Solution Supplier
Solution Supplier

How can I loop through a list as soruce in Power Query?

Hello.

I am creating a model based on DMV's in Power Query, and now I want to loop through a list of all databases in one workspace, so I dont need one model for each database, but instad I want to have all the databases in one model.

So, this is my M code:
let
Tables = AnalysisServices.Database(Server, Database, [Query="select * from $SYSTEM.TMSCHEMA_TABLES", Implementation="2.0"])
in
Tables

 

The Server is a Parameter containing the XMLA endpoint URL to the workspace:
powerbi://api.powerbi.com/v1.0/myorg/WorkspaceName


The Database is just the name of the model:
ModelName

 

Now I want to have a list of all the models in one workspace, and loop throgh this in my m code:

let
Tables = AnalysisServices.Database(Server, "Here I want to loop through a list of Databases (power bi models), [Query="select * from $SYSTEM.TMSCHEMA_TABLES", Implementation="2.0"])
in
Tables

 

I actually want to get the list with rest API, so the list will therefore also be a table in Power query (I'm using the custom connector for API to get this list of datasets in a workspace).

 

Can someone please help me here? Thanks 🙂

Br

Marius

2 REPLIES 2
mariussve1
Solution Supplier
Solution Supplier

Not sure if this is correct, but my query to extract the list of models with API is now converted to a list. I can now use this list as a query into the Database parameter. I now want to invoke this list so it can loop through, but still stucked.

Marius

You can loop through your list with List.Generate or List.Accumulate but it would be easier to just convert your initial list to a table and then add a custom column where you concatenate the dataset id into an API call on each row.

 

Pat

 

Microsoft Employee

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors