cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
cesarvaldez
Helper II
Helper II

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 III
Super User III

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 III
Super User III

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

Helpful resources

Announcements
MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

July 2021 Update 768x460.png

Check it out!

Click here to read more about the July 2021 Updates

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Top Solution Authors