Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Estimados
Espero que se encuentren muy bien.
He estado intentando hacer un total acumulativo por clasificación en el Query; sin embargo, no he encontrado la formula correcta que me permita hacerlo. Lo que necesito es lo siguiente:
SECTOR | NUMERO ID | INGRESO | TOTAL ACUMULADO |
Agricultura | 999999999 | 10.000 | 10.000 |
Agricultura | 111111111 | 20.000 | 30.000 |
Agricultura | 222222222 | 30.000 | 60.000 |
Biotecnología | 333333333 | 5.000 | 5.000 |
Biotecnología | 444444444 | 2.000 | 7.000 |
Petroleo | 555555555 | 30.000 | 30.000 |
Energía | 666666666 | 4.000 | 4.000 |
Energía | 777777777 | 5.000 | 9.000 |
Necesito que el total acumulado se vaya sumando de acuerdo al sector, es decir, cada sector inicie con su propio acumulado. En el ejemplo planateado tengo 4 sectores, pero en la realidad tengo como 500 sectores por eso necesito que la formula me tome la calsificación de manera automatica en el Query.
Si alguien ha tenido el caso o sabe qeu formula puedeo aplicar para lograr el acumulado por calsificaión en en power Query, le agradecería un monton. Gracias por su tiempo.
Solved! Go to Solution.
Hi @JANINA ,
Try this code on Power Query (Advanced Editor):
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckwvykwuzSkpLUpU0lGyhAEg29BAz8DAAMGI1UFXbQgDQLYRTLUxLtVGMIBQpKNkhlDtlJlfkpqcl5+Tn354LUiDMQwA2aZQ9aa4lZvAAMguqHJzuPKA1JKi/JzUfJAZMIDsECRnu+alFkHNNIMBkPlQlSbYFJrDAJJbLSEKYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ECTOR = _t, #"NUMERO ID" = _t, INGRESO = _t, #"TOTAL ACUMULADO" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ECTOR", type text}, {"NUMERO ID", Int64.Type}, {"INGRESO", Int64.Type}, {"TOTAL ACUMULADO", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each let
_ector = [ECTOR],
_index = [Index]
in
List.Accumulate(Table.SelectRows(#"Added Index", each [ECTOR] = _ector and [Index] <= _index)[INGRESO], 0,
(s,c) => s+c))
in
#"Added Custom"
Hi @JANINA ,
Try this code on Power Query (Advanced Editor):
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WckwvykwuzSkpLUpU0lGyhAEg29BAz8DAAMGI1UFXbQgDQLYRTLUxLtVGMIBQpKNkhlDtlJlfkpqcl5+Tn354LUiDMQwA2aZQ9aa4lZvAAMguqHJzuPKA1JKi/JzUfJAZMIDsECRnu+alFkHNNIMBkPlQlSbYFJrDAJJbLSEKYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ECTOR = _t, #"NUMERO ID" = _t, INGRESO = _t, #"TOTAL ACUMULADO" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ECTOR", type text}, {"NUMERO ID", Int64.Type}, {"INGRESO", Int64.Type}, {"TOTAL ACUMULADO", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 0, 1),
#"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each let
_ector = [ECTOR],
_index = [Index]
in
List.Accumulate(Table.SelectRows(#"Added Index", each [ECTOR] = _ector and [Index] <= _index)[INGRESO], 0,
(s,c) => s+c))
in
#"Added Custom"
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.