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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
LoloGox
Frequent Visitor

Elegir el registro con la actualización más reciente

Hola, tengo un caso en el que tengo tres registros con el mismo IDREGISTRO pero con diferentes ESTADO y necesito elegir el registro con la fecha más reciente. ¿Se puede realizar en Power Query? ¿Cómo prodría hacerlo?

 

AÑOMESIDREGISTROESTADO
20229RT2325963Asignado
202210RT2325963Pendiente
202211RT2325963Pendiente
20232RT2325963Cerrado
202210RT9899967Asignado
20232RT9899967Cerrado

 

Gracias.

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

@LoloGox ,

Creé un archivo pbix de muestra (ver el archivo adjunto), verifique si eso es lo que desea.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjIwMlLSUbIE4qAQI2MjU0szYyDbsbg4Mz0vNUUpVgeuxtAATZFrYlFRZl46ihpD/GpAQkZoSpxz8oux2mRpYWlpaWaOxTkIYxBqYMbEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [YEAR = _t, MY = _t, IDREGISTRO = _t, ESTADO = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"YEAR", Int64.Type}, {"MY", Int64.Type}, {"IDREGISTRO", type text}, {"ESTADO", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"IDREGISTRO"}, {{"Most recent date", each List.Max([YEAR]), type nullable number}, {"Details", each _, type table [YEAR=nullable number, MY=nullable number, IDREGISTRO=nullable text, ESTADO=nullable text]}}),
    #"Expanded Details" = Table.ExpandTableColumn(#"Grouped Rows", "Details", {"YEAR", "MY", "ESTADO"}, {"YEAR", "MY", "ESTADO"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Details", "Flag", each if [Most recent date]=[YEAR] then 1 else 0),
    #"Filtered Rows" = Table.SelectRows(#"Added Custom", each ([Flag] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Most recent date", "Flag"})
in
    #"Removed Columns"

yingyinr_0-1675841040793.png

Saludos

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors
Top Kudoed Authors