Forum Discussion
luis-fer-va
1 year agoFrequent Visitor
projection in power query moving average
Hola expertos, Estoy trabajando en una proyección para estimar los valores de los próximos 6 meses. El proceso varía según el parámetro seleccionado. Por ejemplo, si la proyección e...
- Anonymous1 year ago
Hi luis-fer-va
You can refer to the following code in power query.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bc49CoAwDAXgu2Tu0Nj/W4hr6SDSRQRBvD/2LZJAhwz5yAuvVuJMhnjM1veLmqmUIYuUAHFSPMSrlB1bkJLwI0pxSCQpDMlSCv4UJWjHVsVQhlVrjwNWtQE4XJ/77Mf7m59YmFicWJpYltY+", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Value = _t, Index = _t, Mark_Real_Project = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Value", Int64.Type}, {"Index", Int64.Type}}), #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each let a=Table.SelectRows(#"Changed Type",each [Mark_Real_Project]="Real"), b=List.Max(a[Index]), c=List.LastN(a[Value],6), d=Table.RowCount(#"Changed Type"), e=List.Generate( ()=>[x=0,y=c], each [x]<=d, each [y=List.Combine({[y],{List.Average(List.LastN([y],6))}}),x=[x]+1], each List.Average(List.LastN([y],6)) ), f= if [Mark_Real_Project]="Real" then [Value] else e{[Index]-b-1} in f) in #"Added Custom"Ouptut
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
luis-fer-va
1 year agoFrequent Visitor
Muchas gracias Anonymous por tu ayuda, era justo lo que estaba buscando.