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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
J3
Frequent Visitor

Sumar con filtros en DAX

Hola,

 

Necesito sumar ventas por período para tiendas. Tengo 2 unidades negocio y cada unidad de negocio tiene una cantidad X de tiendas. Necesito obtener la suma de ventas para cada tienda en período 2021 y 2022 con una formula en DAX, ya que luego necesito dividir eso por el promedio de superficie por período para cada tienda.

J3_0-1692740523742.png

ejemplo : para 2021 tienda 1 necesito ventas totales (300+200+300) divido por el promedio de superficie de esa tienda (1200+1200+1000/3), lo mismo para cada tienda de cada unidad de negocio. 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @J3 

You can put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdBRCoAwCAbgu/i8B/23RT3WNcbuf42GFTFS6cEN/PgRbY2EEu2jMvN4BfqBIdTTq1db2FY/e4wq2l5tRIRmEvfQqu3NRkQo3kxrF8xa5zvMWqqXNbZBdIcfyWebJcIcoXywnw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Tienda = _t, #"Unidad de negocio " = _t, Venta = _t, #"Superficie venta" = _t, fecha = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Tienda", Int64.Type}, {"Unidad de negocio ", type text}, {"Venta", Int64.Type}, {"Superficie venta", Int64.Type}, {"fecha", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Tienda", "Unidad de negocio ", "fecha"}, {{"Sum_ve", each List.Sum([Venta]), type nullable number}, {"avg_su", each List.Average([Superficie venta]), type nullable number}, {"Data", each _, type table [Tienda=nullable number, #"Unidad de negocio "=nullable text, Venta=nullable number, Superficie venta=nullable number, fecha=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [Sum_ve]/[avg_su]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type number}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Changed Type1", "Data", {"Venta", "Superficie venta"}, {"Venta", "Superficie venta"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Data",{"Tienda", "Unidad de negocio ", "fecha", "Venta", "Superficie venta", "Sum_ve", "avg_su", "Custom"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Custom", "Sum_ve/avg_su"}})
in
    #"Renamed Columns"

Output

vxinruzhumsft_0-1692755304488.png

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.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

Hi @J3 

You can put the following code to advanced editor in power query

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jdBRCoAwCAbgu/i8B/23RT3WNcbuf42GFTFS6cEN/PgRbY2EEu2jMvN4BfqBIdTTq1db2FY/e4wq2l5tRIRmEvfQqu3NRkQo3kxrF8xa5zvMWqqXNbZBdIcfyWebJcIcoXywnw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Tienda = _t, #"Unidad de negocio " = _t, Venta = _t, #"Superficie venta" = _t, fecha = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Tienda", Int64.Type}, {"Unidad de negocio ", type text}, {"Venta", Int64.Type}, {"Superficie venta", Int64.Type}, {"fecha", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Tienda", "Unidad de negocio ", "fecha"}, {{"Sum_ve", each List.Sum([Venta]), type nullable number}, {"avg_su", each List.Average([Superficie venta]), type nullable number}, {"Data", each _, type table [Tienda=nullable number, #"Unidad de negocio "=nullable text, Venta=nullable number, Superficie venta=nullable number, fecha=nullable number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each [Sum_ve]/[avg_su]),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Custom", type number}}),
    #"Expanded Data" = Table.ExpandTableColumn(#"Changed Type1", "Data", {"Venta", "Superficie venta"}, {"Venta", "Superficie venta"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Data",{"Tienda", "Unidad de negocio ", "fecha", "Venta", "Superficie venta", "Sum_ve", "avg_su", "Custom"}),
    #"Renamed Columns" = Table.RenameColumns(#"Reordered Columns",{{"Custom", "Sum_ve/avg_su"}})
in
    #"Renamed Columns"

Output

vxinruzhumsft_0-1692755304488.png

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.

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors