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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Syndicate_Admin
Administrator
Administrator

Power Query: creación de columnas clave basadas en nombres de columna y valores de fila

Estoy buscando crear una columna de "clave" con los únicos nombres y valores de columna para aquellos que no son nulos.

Un ejemplo es...

| Un | B | C | ->>> | | clave

| 1 | | nulo 3 | ->>> "A=1,C=3"

| | nulo 2 | | nulo ->>> "B=2"

| 2 | 4 | 5 | ->>> "A=2,B=4,C=5"

¿Hay alguna forma de extraer solo nombres de columna donde el valor no es nulo y crear una columna clave como la anterior?

1 REPLY 1
Syndicate_Admin
Administrator
Administrator

HI @spencerhoyle ,

En mi opinión, debe crear tres columnas, luego combinar:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUQKhWJ1oEG2ExAYiYzDbECoB5MUCAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [a = _t, b = _t, c = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"a", Int64.Type}, {"b", Int64.Type}, {"c", Int64.Type}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Custom1", each if [a] is null and [b] is null  then "" 
else if  [a] <>null and [b] is null  then "a="&Number.ToText([a])   else   "a="&Number.ToText([a])&","),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom2", each if [b] is null and [c] is null  then "" 
else if  [b] <>null and [c] is null  then "b="&Number.ToText([b])   else   "b="&Number.ToText([b])&","),
    #"Added Custom2" = Table.AddColumn(#"Added Custom1", "Custom3", each if [c] is null then "" else   "c="&Number.ToText([c])),
    #"Added Custom3" = Table.AddColumn(#"Added Custom2", "Final", each [Custom1]&[Custom2]&[Custom3]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom3",{"Custom1", "Custom2", "Custom3"})
in
    #"Removed Columns"

vluwangmsft_0-1662713802238.png


Si esta publicación ayuda, considere Aceptarla como la solución para ayudar a los otros miembros a encontrarla más rápidamente.

Saludos
Lucien

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

Top Solution Authors
Top Kudoed Authors