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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

How to make a do loop with a parameters list in M Query

Hello,

 

I have defined two parameters (StartingDate and EndingDate).

The possible values of StartingDate are:

201001

201101

...

201901

 

The possible values of EndingDate are:

201012

201112

...

201912

 

Those parameters are set as text variable because, I tried with numerical parameters and it did not work.

See the query below:

 

= Sql.Database("ServerName", "DatabaseName", [Query="Select *#(lf)from Dim.CalendarPeriod cp#(lf)where cp.FiscalPeriodSkey between " & StartingDate & " and " & EndingDate & "#(lf)", MultiSubnetFailover=true])

 

By the help of the above mentioned scritp, it is possible to load just a part of the table.

 

Now let's say that 

table1 will have the data for FiscalPeriodSkey between 201001 (first value of StartingDate) and 201012 (first value of EndingDate)

Table2 will have the data for FiscalPeriodSkey between 201101 (second value of StartingDate) and 201112 (second value of EndingDate)

... and so on.

If each parameter has 10 possible values, how can we make a do loop in m-Query in order to create Table1, Table2,..., Table10

 

Thanks in advance for your help

alepage

 

 

 

 

1 REPLY 1
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @Anonymous ,

Based on my research, I am afraid that Power BI could not support this loop with M.

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

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