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
JUAN_1969
Helper I
Helper I

Copiar datos de una columna en otra ya existente

Muy buenas y gracias por anticipada por ayuda.

Estoy confeccionando una consulta desde el editor de Power Query en Power Bi, y después de una combinación de dos tablas de tipo Externa, quiero cambiar los valores null de una columna por valores de otra columna.

Lo que podido hacer con una columna condicional, y algunos pasos más, pero me gustaria en una instrucción única, si es que es posible.

Resumiendo, si una columna A tiene valores null, cambiar el nulo en esa columna A, por los valores de otra columna B.

 

Muchas gracias.

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

Hello @JUAN_1969 

 

you can use Table.ReplaceValue. See this example how it's working in your scenario

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTJUitWJVkoCssCMZCDDGMxKgQmlAhmmYFYaWCgWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [A = _t, B = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"A", type text}, {"B", Int64.Type}}),
    Replace = Table.ReplaceValue
    (
        #"Changed Type",
        each [B],
        each if [B]=null then [A] else [B],
        Replacer.ReplaceValue,
        {"B"}

    )
in
    Replace

 

Copy paste this code to the advanced editor in a new blank query to see how the solution works.

If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too

Have fun

Jimmy

 

 

 

 

Gracias Jimmy por la entrada.
Pero mi conocimiento es limitado en power bi, sería demasiado pedir una pequeña aclaración sobre la respuesta que me da. Lo que hace cada instrucción.
Sí, gracias.

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.

Top Solution Authors
Top Kudoed Authors