cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Zyg_D
Responsive Resident
Responsive Resident

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
Responsive Resident
Responsive Resident

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
Responsive Resident
Responsive Resident

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
Super User
Super User

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
Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

charticulator_carousel_with_text (1).png

Charticulator Design Challenge

Put your data visualization and design skills to the test! This exciting challenge is happening now through May 31st!

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Power BI Release May 2022 768x460.png

Check it out!

Click here to read more about the May 2022 updates!

Top Kudoed Authors