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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
ADI1212
Regular Visitor

Expression.Error: We cannot apply field access to the type Number.

hi all!

 

im trying to generate a list of years in a custom column

i have a first year and last year columns

the list should list all years from the first year until the last year

 

i tried the following:

Table.AddColumn(#"Filtered Rows", "Custom", each

List.Generate (() => [#"First year"], each _ <[#"Last year "], each _ +1 ))

 

but i always get this error :

 

Expression.Error: We cannot apply field access to the type Number.
Details:
Value=2022
Key=Last year 

 

anybody knows how to solve this?

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @ADI1212 ,

In your case, it’s being evaluated in the context of the individual numbers generated by , not in the context of the table rows. you need to reference the columns outside of the function. Here’s how you can modify your code:
Please try like:

let
startYear = [#"First year"],
endYear = [#"Last year"]
in
List.Generate(() => startYear, each _ <= endYear, each _ + 1)

vcgaomsft_0-1694671056572.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @ADI1212 ,

In your case, it’s being evaluated in the context of the individual numbers generated by , not in the context of the table rows. you need to reference the columns outside of the function. Here’s how you can modify your code:
Please try like:

let
startYear = [#"First year"],
endYear = [#"Last year"]
in
List.Generate(() => startYear, each _ <= endYear, each _ + 1)

vcgaomsft_0-1694671056572.png

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors