Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!
hola
Quiero calcular los valores de amortización para cada una de mis filas de tabla de órdenes.
Mi mesa de pedidos se ve así.
Centro de ganancias | fecha | Cantidad(in M) | geo | Amortización del período | Fecha de inicio de amortización | Fecha de finalización de la amortización |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 |
P001 | Fy21Q1M2 | 14 | India | 13 | 2/1/2020 | 3/1/2021 |
P001 | Año Fiscal 21T1M3 | 14 | India | 13 | 3/1/2020 | 4/1/2021 |
P002 | Año Fiscal 21T1M1 | 19 | India | 13 | 4/1/2020 | 5/1/2021 |
P002 | Fy21Q1M2 | 13 | India | 13 | 5/1/2020 | 6/1/2021 |
P002 | Año Fiscal 21T1M3 | 16 | India | 13 | 6/1/2020 | 7/1/2021 |
P003 | Año Fiscal 21T1M1 | 14 | nos | 13 | 7/1/2020 | 8/1/2021 |
P003 | Fy21Q1M2 | 18 | nos | 13 | 8/1/2020 | 9/1/2021 |
P003 | Año Fiscal 21T1M3 | 11 | nos | 13 | 9/1/2020 | 10/1/2021 |
P004 | Año Fiscal 21T1M1 | 18 | nos | 13 | 10/1/2020 | 11/1/2021 |
P004 | Fy21Q1M2 | 17 | nos | 13 | 11/1/2020 | 12/1/2021 |
P004 | Año Fiscal 21T1M3 | 18 | nos | 13 | 12/1/2020 | 1/1/2022 |
Dado que mi período de amortización es de 13 meses, significa que la diferencia entre la fecha de inicio de amortización y la fecha de finalización de amortización es de 13 meses
Based on this information I want to create an M table that will create 14(Amortization Period + 1) rows for all the months between Fecha de inicio de amortización and Fecha de finalización de la amortización with Año Mesón(Output column) as an additional column that traverses each month between the start and end month
Así que mi salida debería verse así.
A continuación se muestra la salida de la fila 1. Del mismo modo, se crearán 14 filas para cada fila de la tabla anterior
Centro de ganancias | fecha | Cantidad(in M) | geo | Amortización del período | Fecha de inicio de amortización | Fecha de finalización de la amortización | Año Mesón |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 1/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 2/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 3/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 4/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 5/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 6/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 7/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 8/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 9/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 10/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 11/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 12/1/2020 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 1/1/2021 |
P001 | Año Fiscal 21T1M1 | 19 | India | 13 | 1/1/2020 | 2/1/2021 | 2/1/2021 |
¿Cómo puedo hacer esto en código m?
Solved! Go to Solution.
@klehar
Pegue el código que se indica a continuación en una consulta en blanco y compruebe los pasos:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hdKxCgMhDAbgd3E+OBM99V6g0KHQUjqUw6HQpUvff+zpVXL+NHQJEfLpL2RZzNlaMoM53JkudCotzWs5vp+vRzm4UkYa2bJdW95aMnlAy2XSo2WxTrfup3ViPVj+l9mLnXTLbbyzk9ig25o5oA1iI1gHmct/b9cGo8Ckwxo4dTAJnHVY01IHZ4FkQXrI2j/Zxislnda0sae7ZSLcJg954dXdLn1vYZPzBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Profit Center" = _t, Date = _t, #"Amount(in M)" = _t, Geo = _t, #"Period Amortization" = _t, #"Amortization Start Date" = _t, #"Amortization End Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Profit Center", type text}, {"Date", type text}, {"Amount(in M)", Int64.Type}, {"Geo", type text}, {"Period Amortization", Int64.Type}, {"Amortization Start Date", type date}, {"Amortization End Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {0..13}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Year Month", each Date.AddMonths([Amortization Start Date],[Custom])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
#"Removed Columns"
@klehar
Pegue el código que se indica a continuación en una consulta en blanco y compruebe los pasos:
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("hdKxCgMhDAbgd3E+OBM99V6g0KHQUjqUw6HQpUvff+zpVXL+NHQJEfLpL2RZzNlaMoM53JkudCotzWs5vp+vRzm4UkYa2bJdW95aMnlAy2XSo2WxTrfup3ViPVj+l9mLnXTLbbyzk9ig25o5oA1iI1gHmct/b9cGo8Ckwxo4dTAJnHVY01IHZ4FkQXrI2j/Zxislnda0sae7ZSLcJg954dXdLn1vYZPzBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Profit Center" = _t, Date = _t, #"Amount(in M)" = _t, Geo = _t, #"Period Amortization" = _t, #"Amortization Start Date" = _t, #"Amortization End Date" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Profit Center", type text}, {"Date", type text}, {"Amount(in M)", Int64.Type}, {"Geo", type text}, {"Period Amortization", Int64.Type}, {"Amortization Start Date", type date}, {"Amortization End Date", type date}}),
#"Added Custom" = Table.AddColumn(#"Changed Type", "Custom", each {0..13}),
#"Expanded Custom" = Table.ExpandListColumn(#"Added Custom", "Custom"),
#"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Year Month", each Date.AddMonths([Amortization Start Date],[Custom])),
#"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom"})
in
#"Removed Columns"
User | Count |
---|---|
1 | |
1 | |
1 | |
1 | |
1 |