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
Anonymous
Not applicable

Convierta filas en columnas con Distinct

Hola a todos 🙂
Mi tabla sigue esta estructura:

Id Nivel Código
111D53.1
111K75.1
222H82.1
333G75.1
333G82.1

Me gustaría crear una nueva tabla y, en esa tabla, cada identificador debe aparecer solo una vez y sus valores Level se convertirán en columnas y valores de código para asociarse a estas columnas. Sobre la base de la tabla de ejemplo anterior, el resultado esperado sería el siguiente:

Id D KGYH
11153.1 75.1
222 82.1
333 75.1/82.1


¿Es posible hacer algo así?

1 ACCEPTED SOLUTION
Fowmy
Super User
Super User

@req7

En Power Query, seleccione Columna LEVEL, vaya a la pestaña Transformar y haga clic en Columna dinámica.
En la columna Valor, elija CODE, Se pivotará como esperaba

Fowmy_0-1597337455296.png


________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

Youtube Linkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@req7 , Puede pivotar

https://radacad.com/pivot-and-unpivot-with-power-bi

O puede usar matriz visual, poner id en fila y nivel en columna y código en el valor

¡Siempre más de una manera de despellejar a un gato!





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Baskar
Resident Rockstar
Resident Rockstar
westwrightj
Resolver III
Resolver III

Hola @req7

Creo que podría tener una solución viable

He utilizado los mismos datos que usted para las pruebas

westwrightj_0-1597337242082.png

Debería poder realizar este lado de Power Query mediante una combinación de agrupación, un poco de manipulación M y un pivote.

He seguido adelante y copiado los pasos que he dado a continuación desde el editor avanzado y la salida que había conseguido

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQ0VNJRcgFiU2M9Q6VYHZiQNxCbm0KFjIyMgFwPILYwggoZGxsDue7IqhBCEFWxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [ID = _t, Level = _t, Code = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Level", type text}, {"Code", type text}}),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Unique ID", each [ID]&"_"&[Level]),
    #"Grouped Rows" = Table.Group(#"Added Custom", {"ID", "Level"}, {{"Values", each Text.Combine([Code], "/"), type nullable text}}),
    #"Pivoted Column" = Table.Pivot(#"Grouped Rows", List.Distinct(#"Grouped Rows"[Level]), "Level", "Values")
in
    #"Pivoted Column"

westwrightj_1-1597337845743.png

Primero comience realizando un grupo por, pero tendrá que cambiar la línea M que se introduce automáticamente desde List.Sum a lo que he incluido en mis pasos como "Text.Combine". Esto tendrá en cuenta los valores múltiples de una columna individual.

Lo único con esta solución es que esos dos valores se tratan como texto. Si desea que sean numéricos, es posible que necesite una solución dax-forward.

Fowmy
Super User
Super User

@req7

En Power Query, seleccione Columna LEVEL, vaya a la pestaña Transformar y haga clic en Columna dinámica.
En la columna Valor, elija CODE, Se pivotará como esperaba

Fowmy_0-1597337455296.png


________________________

¿He respondido a tu pregunta? Marque este post como una solución, esto ayudará a otros!.

Haga clic en el icono Thumbs-Up a la derecha si le gusta esta respuesta 🙂

Youtube Linkedin

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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.