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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Anonymous
Not applicable

Transponer tabla con tres campos para transponer y dos columnas de valor

Hola

He importado una tabla con 5 columnas: YEAR_QUARTER, YEAR_QUARTER_ORDER, LEVEL, PERCENTAGE_QUARTER y PERCENTAGE_YEAR

YEAR_QUARTERYEAR_QUARTER_ORDERNivelPERCENTAGE_QUARTERPERCENTAGE_YEAR
Q1 201920191Este97,5697,56
Q1 201920191Oeste95,8795,87
Q1 201920191Total96,4696,46
Q2 201920192Este99,3998,48
Q2 201920192Oeste100,7498,31
Q2 201920192Total100,2798,37
2019 Q320193Este100,1898,49
2019 Q320193Oeste98,7497,95
2019 Q320193Total99,2498,14
Q4 201920194Este95,9097,32
Q4 201920194Oeste94,3698,37
Q4 201920194Total94,9098,00
2020 Q120201Este97,5097,50
2020 Q120201Oeste98,8698,86
2020 Q120201Total98,3898,38
2020 Q220202Este95,7096,60
2020 Q220202Oeste101,50100,18
2020 Q220202Total99,4798,93

Necesito transponer esta tabla de tal manera que obtengo una fila por valor de YEAR_QUARTER, 3 columnas - una por NIVEL - para PERCENTAGE_QUARTER y 3 columnas - una por NIVEL - para PERCENTAGE_YEAR.

YEAR_QUARTERYEAR_QUARTER_ORDERPERCENTAGE_QUARTER_EASTPERCENTAGE_QUARTER_WESTPERCENTAGE_QUARTER_TOTALPERCENTAGE_YEAR_EASTPERCENTAGE_YEAR_WESTPERCENTAGE_YEAR_TOTAL
Q1 20192019197,5695,8796,4697,5695,8796,46
Q2 20192019299,39100,74100,2798,4898,3198,37
2019 Q320193100,1898,7499,2498,4997,9598,14
Q4 20192019495,9094,3694,9097,3298,3798,00
2020 Q12020197,5098,8698,3897,5098,8698,38
2020 Q22020295,70101,5099,4796,60100,1898,93

¿Cómo puedo hacer esto?

Gracias

R.W.

2 REPLIES 2
Anonymous
Not applicable

Hola @RudyWelvaert ,

Puede realizar algunas transformaciones en Power Query Editor para lograrlo:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("ddI9CsMwDAXgq5TMGmRZ/hszZCuU0kCHkPtfo3atyA7Y08vwYV4kHcdCaNLjbRb4f5Xc1s+eIwVwXvOEEf1ulTqIQXNM99e+PovxwF6zWRJLXYMENpWMwHFCpYFBhMDVWjOxV4WCKQju+1rBtnUo1kQpkSb2GkOUDgGSm1AdQwKSvoY7y2K5G4ODhPVZSxN6NWCwfvBjPdUGLM9GQBRLeC0t6/spoOaYthlErzmm2iC3jJrNkli6zSBgvRqPE6qnYGpbWd0Yd3tgOYW8n/P8AQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [YEAR_QUARTER = _t, YEAR_QUARTER_ORDER = _t, LEVEL = _t, PERCENTAGE_QUARTER = _t, PERCENTAGE_YEAR = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"YEAR_QUARTER", type text}, {"YEAR_QUARTER_ORDER", Int64.Type}, {"LEVEL", type text}, {"PERCENTAGE_QUARTER", Int64.Type}, {"PERCENTAGE_YEAR", Int64.Type}}),
    #"Unpivoted Only Selected Columns" = Table.Unpivot(#"Changed Type", {"PERCENTAGE_QUARTER", "PERCENTAGE_YEAR"}, "Attribute", "Value"),
    #"Added Custom" = Table.AddColumn(#"Unpivoted Only Selected Columns", "Custom", each [Attribute]&"_"&[LEVEL]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom",{"LEVEL", "Attribute"}),
    #"Pivoted Column" = Table.Pivot(#"Removed Columns", List.Distinct(#"Removed Columns"[Custom]), "Custom", "Value", List.Sum)
in
    #"Pivoted Column"

Transpose table.JPG

Saludos

Rena

parry2k
Super User
Super User

@RudyWelvaert el modelo unpivoted es mejor, por qué no usar la matriz visual con Level on Column y el valor en las filas.

Me gustaría elogiossi mi solución ayudara.👉Si puedes pasar tiempo publicando la pregunta, también puedes hacer esfuerzos para dar a Kudos quien haya ayudado a resolver tu problema. ¡Es una muestra de agradecimiento!

Visítenos enhttps://perytus.com, su ventanilla única para proyectos/formación/consulta relacionadas con Power BI.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.

Top Solution Authors
Top Kudoed Authors