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
Anonymous
Not applicable

Reemplace los valores por la última fecha Power Query

Estoy tratando de reemplazar la dirección con la dirección de la calle de 2020 (fecha más reciente). Algunas filas incluyen City, State y Zip, pero ya tengo columnas para aquellos, así que solo quiero mantener una dirección estándar. THis me ayudará cuando tenga que pivotar más tarde, pero necesito esto primero para darme una fila por tienda.Capture.JPG

1 ACCEPTED SOLUTION
edhans
Super User
Super User

Echa un vistazo al siguiente código M para hacer esto:

Se convierte en esto

2020-04-23 12_13_18-Untitled - Power Query Editor.png

en esto:

2020-04-23 12_13_31-Untitled - Power Query Editor.png

Código M:

1) En Power Query, seleccione Nuevo origen y, a continuación, Consulta en blanco
2) En la cinta inicio, seleccione el botón "Editor avanzado"
3) Retire todo lo que ve, luego pegue el código M que le he dado en ese cuadro.
4) Pulse Hecho

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUosTkkDUkYGRgZKsToIMSgGSxlagqWSQBwTYyNjE0OjQmMTZF0gqZKMDKCe9HIghuuKBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Customer = _t, Address = _t, Year = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Address", type text}, {"Year", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Customer"}, {{"All Rows", each _, type table [Customer=text, Address=text, Year=number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Latest Address", each Table.Max([All Rows],"Year")[Address]),
    #"Expanded All Rows" = Table.ExpandTableColumn(#"Added Custom", "All Rows", {"Address", "Year"}, {"Address", "Year"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded All Rows",{"Customer", "Latest Address", "Year"})
in
    #"Removed Other Columns"


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

1 REPLY 1
edhans
Super User
Super User

Echa un vistazo al siguiente código M para hacer esto:

Se convierte en esto

2020-04-23 12_13_18-Untitled - Power Query Editor.png

en esto:

2020-04-23 12_13_31-Untitled - Power Query Editor.png

Código M:

1) En Power Query, seleccione Nuevo origen y, a continuación, Consulta en blanco
2) En la cinta inicio, seleccione el botón "Editor avanzado"
3) Retire todo lo que ve, luego pegue el código M que le he dado en ese cuadro.
4) Pulse Hecho

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUUosTkkDUkYGRgZKsToIMSgGSxlagqWSQBwTYyNjE0OjQmMTZF0gqZKMDKCe9HIghuuKBQA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type text) meta [Serialized.Text = true]) in type table [Customer = _t, Address = _t, Year = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Customer", type text}, {"Address", type text}, {"Year", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Customer"}, {{"All Rows", each _, type table [Customer=text, Address=text, Year=number]}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Latest Address", each Table.Max([All Rows],"Year")[Address]),
    #"Expanded All Rows" = Table.ExpandTableColumn(#"Added Custom", "All Rows", {"Address", "Year"}, {"Address", "Year"}),
    #"Removed Other Columns" = Table.SelectColumns(#"Expanded All Rows",{"Customer", "Latest Address", "Year"})
in
    #"Removed Other Columns"


Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

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.