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

Join the FabCon + SQLCon recap series. Up next: Power BI, Real-Time Intelligence, IQ and AI, and Data Factory take center stage. All sessions are available on-demand after the live show. Register now

Reply
Anonymous
Not applicable

List.Generate() Passing Parameters - Power Query

Hi Community,

 

I am using List.Generate to create a loop function in power query.

This loop is running on start date & end date for each iteration, which I am getting from within the loop.

The starting dates, I have defined , currently within the List.Generate() function. Can these dates be defined out of the list.Generate function.

ie

If I can use startdate and enddate commented in green, instead of hardcoding in List.Generate() here in Red.

I tried using it, but it could not recognize those values.

 

 //StartDate = #date(2018,01,01), 
 //EndDate = #date(2018,01,31), 

	GeneratedList =
	List.Generate(
	()=>[StartDate = #date(2017,11,01),EndDate = Date.AddMonths(StartDate,1),res =FnGetOnePage(StartDate,EndDate)],
	each  [StartDate] < DateTime.Date(DateTime.LocalNow()),
	each [StartDate = Date.AddMonths([StartDate],1),
          EndDate= Date.AddMonths([EndDate],1),
          res = FnGetOnePage(StartDate,EndDate)
              ],
	each[res][profiles]
    ),
     Result = Table.FromRecords(List.Combine(GeneratedList))
   
in
    Result

 Regards

emudria

 

 

 

 

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

Not exactly like yours, but this worked for me:

 

let
 StartDate = #date(2017,01,01), 
 EndDate = #date(2018,01,31),
 GeneratedList = List.Generate(()=>StartDate, each _ < EndDate, each Date.AddMonths(_,1))
in
    GeneratedList


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

3 REPLIES 3
Greg_Deckler
Community Champion
Community Champion

Not exactly like yours, but this worked for me:

 

let
 StartDate = #date(2017,01,01), 
 EndDate = #date(2018,01,31),
 GeneratedList = List.Generate(()=>StartDate, each _ < EndDate, each Date.AddMonths(_,1))
in
    GeneratedList


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

@Greg_Deckler Thanks, its working. 

@Anonymous,

 

Glad to hear that. You may help accept solution. Your contribution is highly appreciated.

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

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.