Forum Discussion
Anonymous
4 years agoNot applicable
Average based on column name and a date reference
Hi, I have a data source structured as follows. It lists daily prices for calendar year stock options. Prices are valid up to 1 April for the respective year you would buy for, e.g. prices for C...
- 4 years ago
Hi Anonymous ,
See if this helps you.
let Origen = Table.FromRows( Json.Document(Binary.Decompress(Binary.FromText("dcu7DcAgDIThXVyfhF+AmQWx/xrgoEhpUn3F3T8naRS2osxBIB8wSRXd0oBo2iDjSAuTTL5FoLZbRP0r+BT+Fjkauh8rI+Semz7ntQE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, #"2008" = _t, #"2009" = _t, #"2010" = _t, #"2011" = _t, #"2012" = _t] ), #"Tipo cambiado" = Table.TransformColumnTypes(Origen, {{"Date", type date}, {"2008", Currency.Type}, {"2009", Currency.Type}, {"2010", Currency.Type}, {"2011", Currency.Type}, {"2012", Currency.Type}}), #"Índice agregado" = Table.AddIndexColumn(#"Tipo cambiado", "Index", 0, 1, Int64.Type), #"Personalizada agregada" = Table.AddColumn( #"Índice agregado", "4 years average", each List.Average( { List.Last(List.Range(List.RemoveNulls(Table.Column(#"Índice agregado", Text.From(Date.Year([Date])))), 0, [Index] + 1)), List.Last(List.Range(List.RemoveNulls(Table.Column(#"Índice agregado", Text.From(Date.Year([Date]) + 1))), 0, [Index] + 1)), List.Last(List.Range(List.RemoveNulls(Table.Column(#"Índice agregado", Text.From(Date.Year([Date]) + 2))), 0, [Index] + 1)), List.Last(List.Range(List.RemoveNulls(Table.Column(#"Índice agregado", Text.From(Date.Year([Date]) + 3))), 0, [Index] + 1)) } ), Currency.Type ) in #"Personalizada agregada"
Anonymous
4 years agoNot applicable
Thanks v-yanjiang-msft this seems to work.
Issue now is the load is 100's of MB, and hasn't stopped.
Have you experienced this before with other calculations?
Cheers,
Ben
v-yanjiang-msft
4 years agoCommunity Support
Hi Anonymous ,
Do you mean it loads slowly because the data model is too big.
Best Regards,
Community Support Team _ kalyj
- Anonymous4 years agoNot applicable
The data source is only 600kB. I'm unsure why introducing a new 'average' column would increase the size of the database >100x?
Cheers
Ben
- v-yanjiang-msft4 years agoCommunity Support
Hi Anonymous ,
Complex operations do use a lot of CPU and memory, maybe that's causing it to load slowly.
Best Regards,
Community Support Team _ kalyj