Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
JANINA
New Member

Saldo Acumulados por clasificación

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:

 

SECTORNUMERO IDINGRESOTOTAL ACUMULADO
Agricultura99999999910.00010.000
Agricultura11111111120.00030.000
Agricultura22222222230.00060.000
Biotecnología3333333335.0005.000
Biotecnología4444444442.0007.000
Petroleo55555555530.00030.000
Energía6666666664.0004.000
Energía7777777775.0009.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.

1 ACCEPTED SOLUTION
camargos88
Community Champion
Community Champion

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"

 

Capture.PNG

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



View solution in original post

2 REPLIES 2
camargos88
Community Champion
Community Champion

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"

 

Capture.PNG

 

 



Did I answer your question? Mark my post as a solution!

Proud to be a Super User!



Hola, Muchas gracias @camargos88 . Me ayudo un monton

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors