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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Zyg_D
Continued Contributor
Continued Contributor

Transformación de 2 columnas a la vez en powerquery-m

Estos son mis datos: 2 columnas originales + 1 hechas de la primera.

dejar que
    Source : Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSo0pNTAwMlO2NDWzVshNLcnIT1HSUYIJmphZ6xaXFJUml5QWpSrF6kQrJefnFZck5pUowJSYGVgja7CwNjR2BhqUWAzUkZuaV6IUGWsA"let _t á ((tiponullabletrueenlatabla detipos [col1 ? _t, col2 - _t]), -
    "Changed Type" - Table.TransformColumnTypes(Source, ?"col1"typetext, •"col2"texto de tipotext?),
    HtmlTable - Table.AddColumn(-"Changed Type""HtmlTable", cada Html.Table([col1],? "HtmlDecoded",":root"?)),
    "Expanded HtmlTable""HtmlTable"," HtmlDecoded","HtmlDecoded" , "HtmlDecoded"-
in
    "Expanded HtmlTable"

data.png

No puedo encontrar una manera de transformar 2 columnas a la vez. ¿Hay uno?

1 ACCEPTED SOLUTION
Zyg_D
Continued Contributor
Continued Contributor

Gracias, @mahoneypat .
Usando tu respuesta pude crear lo que necesitaba.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSo0pNTAwMlO2NDWzVshNLcnIT1HSUYIJmphZ6xaXFJUml5QWpSrF6kQrJefnFZck5pUowJSYGVgja7CwNjR2BhqUWAzUkZuaV6IUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t, col2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}, {"col2", type text}}),
    Decoded = Table.TransformColumns(#"Changed Type", {
        {"col1", each Table.FirstValue(Html.Table(_,{{"HtmlDecoded1",":root"}}))}, 
        {"col2", each Table.FirstValue(Html.Table(_,{{"HtmlDecoded2",":root"}}))} } )
in
    Decoded

View solution in original post

2 REPLIES 2
Zyg_D
Continued Contributor
Continued Contributor

Gracias, @mahoneypat .
Usando tu respuesta pude crear lo que necesitaba.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSo0pNTAwMlO2NDWzVshNLcnIT1HSUYIJmphZ6xaXFJUml5QWpSrF6kQrJefnFZck5pUowJSYGVgja7CwNjR2BhqUWAzUkZuaV6IUGwsA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [col1 = _t, col2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"col1", type text}, {"col2", type text}}),
    Decoded = Table.TransformColumns(#"Changed Type", {
        {"col1", each Table.FirstValue(Html.Table(_,{{"HtmlDecoded1",":root"}}))}, 
        {"col2", each Table.FirstValue(Html.Table(_,{{"HtmlDecoded2",":root"}}))} } )
in
    Decoded

mahoneypat
Employee
Employee

Sí. La función Table.TransformColumns toma una lista de listas como argumento, cada una de las cuales es un nombre de columna y la función que se va a aplicar. A continuación, tomé su M, resalto sus dos primeras columnas y elegí minúsculas en la pestaña Transformar. Este código ahora se puede cambiar para realizar una transformación diferente en cada columna.

• Table.TransformColumns('Expanded HtmlTable','"col1", Text.Lower,type text', 'col2', Text.Lower, type text')

saludos

palmadita





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors