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
Syndicate_Admin
Administrator
Administrator

Combinar o combinar columnas si el encabezado de columna contiene "Tipo"

Hola tengo un conjunto de datos como el siguiente. Puedo combinar manualmente las columnas para que sea como uno. ¿Es posible escribir una condición para combinar las columnas?

Ejemplo: si el nombre del encabezado de columna contiene Type, combine todas esas columnas para crear una nueva columna.

Repollo 1Repollo 2Repollo 3Tipo-123Tipo-456Repollo 8Repollo 10
1 ACCEPTED SOLUTION

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRS0lGCIBOfYBDp7O0CpCx9gIS/v79SbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col 1" = _t, #"Type-000" = _t, #"Type-001" = _t, #"Type-123" = _t, #"Type-456" = _t, #"Col 8" = _t, #"Col 10" = _t]),
    #"Combined Columns" = Table.CombineColumns(Source, List.Select(Table.ColumnNames(Source), each Text.Contains(_, "Type")), each Text.Combine(List.RemoveItems(_, {null, ""}), "|"), "Combined")
in
    #"Combined Columns"

View solution in original post

4 REPLIES 4
Syndicate_Admin
Administrator
Administrator

@CNENFRNL Amablemente ayuda

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRS0lGCIBOfYBDp7O0CpCx9gIS/v79SbCwA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col 1" = _t, #"Type-000" = _t, #"Type-001" = _t, #"Type-123" = _t, #"Type-456" = _t, #"Col 8" = _t, #"Col 10" = _t]),
    #"Combined Columns" = Table.CombineColumns(Source, List.Select(Table.ColumnNames(Source), each Text.Contains(_, "Type")), each Text.Combine(List.RemoveItems(_, {null, ""}), "|"), "Combined")
in
    #"Combined Columns"
Syndicate_Admin
Administrator
Administrator

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcjRS0lHycQwDkiaGLiDSJxhEOnuDOJY+QMLf318pNhYA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Col 1" = _t, #"Col 2" = _t, #"Col 3" = _t, #"Type-123" = _t, #"Type-456" = _t, #"Col 8" = _t, #"Col 10" = _t]),
    #"Combined Columns" = Table.CombineColumns(Source, List.Select(Table.ColumnNames(Source), each Text.Contains(_, "Type")), Combiner.CombineTextByDelimiter("|", QuoteStyle.Csv), "Combined")
in
    #"Combined Columns"

Screenshot 2021-06-01 160130.png

Esto está funcionando, pero estoy recibiendo |||| 4LS|4CKD ya que tengo null para las columnas anteriores (con encabezados Type). ¿Podemos agregar una condición para evitar celdas nulas?

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.