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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Advanced Transpose

Hello, Somebody can help me !

 

I have a database and i want to transpose some informations, Line to colunm. But is not a normal way.

My base is: 

Modelo 1Modelo 1

 

I need to keep the columns: Data, praza, numero_domicilio and tvdomicilio. Parallel i need to transpose the id_parametro and conteudo_parametro. Like this:

Base_Modelo_Final.png

 

Who can help me do this automatically in Power BI?

 

Thanks!

 

1 ACCEPTED SOLUTION
edhans
Community Champion
Community Champion

I think what you want to do is select your ID Parametro column, go to the Transform ribbon, and select Pivot Column. Select the conteudo_parametro as the data value, and then in advanced options, select Don't Aggregate. It would look like this:

edhans_0-1626209509408.png

It turned this:

edhans_1-1626209537062.png

into this:

edhans_2-1626209565964.png

Here is the M code I used if you want to look at it:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jcrJDcAgDETRXnxGwjZkoYCErBUg+m8j4zSAL/4j+bVGEiUqq1AgEbabplzQf5cyIxv1MJYLsrvkilSXtHmMpTJbTpe0x+WSitwumZDHJTPyUu8f", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Code1 = _t, Code2 = _t, Code3 = _t, Data1 = _t, Data2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Data1", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Data1", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Data1", type text}}, "en-US")[Data1]), "Data1", "Data2")
in
    #"Pivoted Column"

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 

If you need more help, please provide us usable data. We cannot work with screenshots for source data, and I'm not keying that in. I just keyed in some random data in Excel.

 

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

View solution in original post

3 REPLIES 3
edhans
Community Champion
Community Champion

I think what you want to do is select your ID Parametro column, go to the Transform ribbon, and select Pivot Column. Select the conteudo_parametro as the data value, and then in advanced options, select Don't Aggregate. It would look like this:

edhans_0-1626209509408.png

It turned this:

edhans_1-1626209537062.png

into this:

edhans_2-1626209565964.png

Here is the M code I used if you want to look at it:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("jcrJDcAgDETRXnxGwjZkoYCErBUg+m8j4zSAL/4j+bVGEiUqq1AgEbabplzQf5cyIxv1MJYLsrvkilSXtHmMpTJbTpe0x+WSitwumZDHJTPyUu8f", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Date = _t, Code1 = _t, Code2 = _t, Code3 = _t, Data1 = _t, Data2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}, {"Data1", Int64.Type}}),
    #"Pivoted Column" = Table.Pivot(Table.TransformColumnTypes(#"Changed Type", {{"Data1", type text}}, "en-US"), List.Distinct(Table.TransformColumnTypes(#"Changed Type", {{"Data1", type text}}, "en-US")[Data1]), "Data1", "Data2")
in
    #"Pivoted Column"

How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.

 

If you need more help, please provide us usable data. We cannot work with screenshots for source data, and I'm not keying that in. I just keyed in some random data in Excel.

 

How to get good help fast. Help us help you.

How To Ask A Technical Question If you Really Want An Answer

How to Get Your Question Answered Quickly - Give us a good and concise explanation
How to provide sample data in the Power BI Forum - Provide data in a table format per the link, or share an Excel/CSV file via OneDrive, Dropbox, etc.. Provide expected output using a screenshot of Excel or other image. Do not provide a screenshot of the source data. I cannot paste an image into Power BI tables.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

Thank you !! have a nice week!

edhans
Community Champion
Community Champion

If that helps you @Anonymous please mark my post as the solution so this thread can be closed and others can see it is solved as well. 



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

February Power BI Update Carousel

Power BI Monthly Update - February 2026

Check out the February 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors