Ron Coderre
Member
- Joined
- Aug 11, 2015
- Messages
- 110
- Reaction score
- 1
- Points
- 16
- Location
- Boston, MA
- Excel Version(s)
- 2013, 2016, O365
Here's my issue....(File attached)
I want to use this table to set the Start, End, and Step values when creating a list for each row.
My first successful attempt, which adds a column of Lists, uses hard-coded values:
My second UN-successful attempt, uses column values in the List.Generate:
It seems to work...but each List in the added column resolves to this error:
Expression.Error: We cannot apply field access to the type Number.
However, if I create this function to create a list:
then this works:
I don't understand why I can pass field values to the function, but cannot use them directly.
I want to use this table to set the Start, End, and Step values when creating a list for each row.
Code:
Name Start1 End1 Step1
Alpha 1 10 1
Bravo 4 8 2
My first successful attempt, which adds a column of Lists, uses hard-coded values:
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Custom", each
List.Generate(()=>1,
each _ <= 10,
each _ + 2))
in
#"Added Custom"
My second UN-successful attempt, uses column values in the List.Generate:
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Custom", each
List.Generate(
()=> _[Start1],
each _ <= [End1],
each _ + [Step1]))
in
#"Added Custom"
It seems to work...but each List in the added column resolves to this error:
Expression.Error: We cannot apply field access to the type Number.
However, if I create this function to create a list:
Code:
(Start as number, End as number, Step as number) =>
let
MyList =
List.Generate(()=>Start,
each _ <= End,
each _ + Step)
in
MyList
then this works:
Code:
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Added Custom" = Table.AddColumn(Source, "Custom", each fnCreateList([Start1],[End1],[Step1]))
in
#"Added Custom"
I don't understand why I can pass field values to the function, but cannot use them directly.