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
NNaj
Helper IV
Helper IV

Convertir código DAX en consulta de potencia

Hola a todos

Estoy buscando convertir el siguiente código en consulta de energía con el fin de despivor mi tabla

Clasificación TOTAL ?
CALCULAR (
SUM ( envíos[Valor] ),
ALLEXCEPT ( envíos, presentaciones[Clasificación], envíos[NombreDeEmem- ) ),
NOT ( ISBLANK ( envíos[Valor] ) )
)
/ CALCULATE (
COUNTA ( envíos[Valor] ),
ALLEXCEPT ( envíos, presentaciones[Clasificación], envíos[NombreDeEmem- ) ),
NOT ( ISBLANK ( envíos[Valor] ) )

Para obtener la siguiente tabla:

table needed.jpg

El DAX anterior se utiliza para sumar todos los valores para todas las manzanas E y S e introducir esto como un total. esto se divide por el recuento de valores para manzana.

Gracias de antemano por su ayuda

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hola @NNaj ,

Puede utilizar la función Table.Group para lograrlo en Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclXSUXIsKMhJBdKGBkqxOhChkNTinESQkClcCKbKFFOVCUQoGEmVEaaQIUIIphFoeiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Classification = _t, Company = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Classification", type text}, {"Company", type text}, {"Value", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Classification", "Company"}, {{"Column", each List.Sum([Value]), type nullable number}, {"Rows", each _, type table [Classification=nullable text, Company=nullable text, Value=nullable number]}}),
    #"Expanded Rows" = Table.ExpandTableColumn(#"Grouped Rows", "Rows", {"Value"}, {"Value"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Rows",{"Classification", "Company", "Value", "Column"})
in
    #"Reordered Columns"​​

Convert DAX code to power query.JPG

También puede consultar la siguiente documentación para lograrlo.

Agrupación de filas con Power BI / Power Query

Saludos

Rena

Community Support Team _ Rena
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

2 REPLIES 2
v-yiruan-msft
Community Support
Community Support

Hola @NNaj ,

Puede utilizar la función Table.Group para lograrlo en Power Query Editor:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WclXSUXIsKMhJBdKGBkqxOhChkNTinESQkClcCKbKFFOVCUQoGEmVEaaQIUIIphFoeiwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Classification = _t, Company = _t, Value = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Classification", type text}, {"Company", type text}, {"Value", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Classification", "Company"}, {{"Column", each List.Sum([Value]), type nullable number}, {"Rows", each _, type table [Classification=nullable text, Company=nullable text, Value=nullable number]}}),
    #"Expanded Rows" = Table.ExpandTableColumn(#"Grouped Rows", "Rows", {"Value"}, {"Value"}),
    #"Reordered Columns" = Table.ReorderColumns(#"Expanded Rows",{"Classification", "Company", "Value", "Column"})
in
    #"Reordered Columns"​​

Convert DAX code to power query.JPG

También puede consultar la siguiente documentación para lograrlo.

Agrupación de filas con Power BI / Power Query

Saludos

Rena

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
HotChilli
Super User
Super User

No creo que nadie quiera realizar ingeniería inversa de ese código y convertirlo en consulta de potencia.

¿Por qué no publicas una muestra de datos (no una imagen) de antes y después y nos dices las condiciones especiales requeridas?

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.