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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
ctrip77
Frequent Visitor

Syntax Error in List.Generate Function

Hi everyone!

Im trying to do a date list (in power Query), starting on a given date and then get the next 4 years.

I did this:

List.Generate(()=> [ x = 1 , y = {}] , each [x] <= 4 , each [x = [x]+1] , each Date.AddYears([Date_start] ,1) )

But Im receiving error, I dont know where is my syntax error, if anybody see it or if there is another solution I would appreciate.

thanks in advance!

1 ACCEPTED SOLUTION
ctrip77
Frequent Visitor

ok, found it:

 

List.Generate( () => [ a = [Date_start], b = Date.AddYears([Date_start] ,4) ], each [a] <= [b], each [ a = Date.AddYears( [a], 1 ), b = [b] ], each [a] )

View solution in original post

3 REPLIES 3
ctrip77
Frequent Visitor

ok, found it:

 

List.Generate( () => [ a = [Date_start], b = Date.AddYears([Date_start] ,4) ], each [a] <= [b], each [ a = Date.AddYears( [a], 1 ), b = [b] ], each [a] )

PattemManohar
Community Champion
Community Champion

@ctrip77  Please try this as a "Custom Column" in Power Query Editor.

 

=List.Numbers(Date.Year([hiredate])+1,4)




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

Proud to be a PBI Community Champion




HotChilli
Super User
Super User

Try this technique (which is good to learn for lots of other functions too)

https://exceleratorbi.com.au/build-reusable-calendar-table-power-query/

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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