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

How to transform row to columns in a new table in Power BI

Hi a try some times made that in Power bi with Transpose and pivot but i cannot obtain the correct result.
This is the original dataOriginal data.JPG

IdentificacionMateriaNroMatriculaCalifFinalCarreraNivelacion
089032185   FISICA13.5INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
089032185   FUNDAMENTOS DE MATEMATICA15.6INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
089032185   FUNDAMENTOS DE QUIMICA16.6INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
089032185   GEOMETRIA Y TRIGONOMETRIA124.2INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
089032185   LENGUAJE Y COMUNICACION124INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
103582771   FISICA230.4INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
103582771   FUNDAMENTOS DE QUIMICA231.4INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
103582771   GEOMETRIA Y TRIGONOMETRIA231.2INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
103582772LENGUAJE Y COMUNICACION218INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A
103582771   FUNDAMENTOS DE MATEMATICA230INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A

Final data.JPG

IdentificacionNroMatriculaCarreraNivelacionFISICAFUNDAMENTOS DE MATEMATICAFUNDAMENTOS DE QUIMICAGEOMETRIA Y TRIGONOMETRIALENGUAJE Y COMUNICACION
089032185   1INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A3.55.66.6.24.224
103582771   2INGENIERIA, CIENCIAS Y CIENCIAS ADMINISTRATIVAS2019-A30.43031.431.218

How to do that?, thanks a lot by the help

Roberth

 

1 ACCEPTED SOLUTION

Hi @Anonymous 

assuming there is a little typo on the row before the last, you can retrieve the result by pivoting on "Materia" with column "Califfinal" in the values. Make sure to choose "Don't aggregate" in the aggregation options:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tdNLDoIwEAbgqxDWSNoiissJjGSMnUZbTIzxbp7FkzkokRgfG2xIX4vOl/Yvp1OqqpUqjK7K66X/0ixdk6caZKKlFXkpPXGLTLgnyJKakGsCnxzHKTSWmHzYQ6ADeNlhlF7NID1nH4WOG7DIwfmkwcRCQGkjWuaL6OiuIzuKixhii85ikGpSQ4bW8bAeUDPPzf/VLXLbwQb7Es52LIesyfHTnCpqVZSVWS71+4PpT1OoPAbxLbw7qWOQv9Ib1Mnpvavf0+sxXUW/2pef8RHoJPN8Aw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Identificacion = _t, Materia = _t, NroMatricula = _t, CalifFinal = _t, Carrera = _t, Nivelacion = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Identificacion", Int64.Type}, {"Materia", type text}, {"NroMatricula", Int64.Type}, {"CalifFinal", type number}, {"Carrera", type text}, {"Nivelacion", type text}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Materia]), "Materia", "CalifFinal")
in
#"Pivoted Column"

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Thanks by the tip, I will be testing this evening
By the moment I resolved the problem using Pivot Column Transform in Power Query Editor

 

Solution.JPG

 

The result

 

result.JPG

 

Thanks a lot

v-eachen-msft
Community Support
Community Support

Hi @Anonymous ,

 

I found that you put "103582772" into the records of "103582771". Do you mean to use the "NroMatricula" to group your data? You could following the following codes:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tZPBDoIwDIZfZeGMZBuieGygkhrXRTdMDPH9X8OiKFGjF/DQrcvS/0v7b12X6HKjc2vKQimVpMmWAlUgiZHIs0JW4gaZ8EiQqoqQK4KgzmMKtSOmEI8Q6QRBKqw2mwUkl/RTvuUaHHL0QdWoHESUGIlFtvov8dCSG3Gr2XENeodRpERAtsbzcB6IdpnZmZF75KaFHfb13rUs7VXk+QmcijM6L0q7Xpu3F9L3ketsdv1vht14ZnbeL8cG5GTHHkj7067+1pT/HefLj7s7OAl4uQI=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Identificacion = _t, Materia = _t, NroMatricula = _t, CalifFinal = _t, Carrera = _t, Nivelacion = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Identificacion", Int64.Type}, {"Materia", type text}, {"NroMatricula", Int64.Type}, {"CalifFinal", type number}, {"Carrera", type text}, {"Nivelacion", type text}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"NroMatricula"}, {{"Identificacion", each List.Min([Identificacion]), type number}, {"Carrera", each _, type table [Identificacion=number, Materia=text, NroMatricula=number, CalifFinal=number, Carrera=text, Nivelacion=text]}}),
    #"Expanded Carrera" = Table.ExpandTableColumn(#"Grouped Rows", "Carrera", {"Materia", "CalifFinal", "Carrera", "Nivelacion"}, {"Carrera.Materia", "Carrera.CalifFinal", "Carrera.Carrera", "Carrera.Nivelacion"}),
    #"Pivoted Column" = Table.Pivot(#"Expanded Carrera", List.Distinct(#"Expanded Carrera"[Carrera.Materia]), "Carrera.Materia", "Carrera.CalifFinal")
in
    #"Pivoted Column"

 

Community Support Team _ Eads
If this post helps, then please consider Accept it as the solution to help the other members find it.
Greg_Deckler
Super User
Super User

@ImkeF 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Hi @Anonymous 

assuming there is a little typo on the row before the last, you can retrieve the result by pivoting on "Materia" with column "Califfinal" in the values. Make sure to choose "Don't aggregate" in the aggregation options:

 

let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("tdNLDoIwEAbgqxDWSNoiissJjGSMnUZbTIzxbp7FkzkokRgfG2xIX4vOl/Yvp1OqqpUqjK7K66X/0ixdk6caZKKlFXkpPXGLTLgnyJKakGsCnxzHKTSWmHzYQ6ADeNlhlF7NID1nH4WOG7DIwfmkwcRCQGkjWuaL6OiuIzuKixhii85ikGpSQ4bW8bAeUDPPzf/VLXLbwQb7Es52LIesyfHTnCpqVZSVWS71+4PpT1OoPAbxLbw7qWOQv9Ib1Mnpvavf0+sxXUW/2pef8RHoJPN8Aw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Identificacion = _t, Materia = _t, NroMatricula = _t, CalifFinal = _t, Carrera = _t, Nivelacion = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Identificacion", Int64.Type}, {"Materia", type text}, {"NroMatricula", Int64.Type}, {"CalifFinal", type number}, {"Carrera", type text}, {"Nivelacion", type text}}),
#"Pivoted Column" = Table.Pivot(#"Changed Type", List.Distinct(#"Changed Type"[Materia]), "Materia", "CalifFinal")
in
#"Pivoted Column"

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

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.