Hi @Sam,
I’m having a hard time understanding List.Generate.
I’m generating a set of rows in a table with the
date and fiscal period.
All seems to be ok but the second row is a duplication of the first.
Where I’m doing wrong?
Thanks
Roberto
List.Generate class.pbix (18.0 KB)
let
Source = List.Generate(
() => [
index = 0,
date = #date(2023, 4, 1),
Period = GetFiscalPeriod(date, 4)
],
each [index] < 70,
each [
index = [index] + 1,
date = Date.AddQuarters([date], 1),
Period = GetFiscalPeriod([date], 4)
],
each Record.FromList(
{[date], [Period]},
{"Data", "Fiscal Period"}
)
),
TableFromList = Table.FromList(
Source,
Splitter.SplitByNothing(),
{"Dates"},
null,
ExtraValues.Error
),
ListOfColumns = Record.FieldNames(
TableFromList[Dates]{0}
),
ExpandedRecords = Table.ExpandRecordColumn(
TableFromList,
"Dates",
ListOfColumns,
ListOfColumns
),
Types = {
{"Data", type date},
{“Fiscal Period”, type text}
},
#"Changed Type" = Table.TransformColumnTypes(
ExpandedRecords,
Types
)
in
#“Changed Type”