Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

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

  • v-danhe-msft's avatar
    v-danhe-msft
    Icon for Microsoft Employee rankMicrosoft Employee

    Hi Anonymous ,

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

     

    Regards,

    Daniel He