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
hnguyen76
Resolver II
Resolver II

PowerQuery Unpivot top rows

Good morning,

Hopefully this is an easy solution to fix but I can't seem to wrap my head around it. I have a source file that gives me data in this format:

Column1Column2Column3Column4Column5
 2019202020202020
 12010203
ID2031000101010151020
ID205500550600650

 

The first row has my year and the second row has my months. I want to dynamically unpivot the data so it could look like this:

Column1Column2Column3Column4
ID2032019121000
ID2032020011010
ID2032020021015
ID2032020031020
ID205201912500
ID205202001550
ID205202002600
ID205202003650


I drill adding a calculated column and using drilldown but it doesn't seem to give me the right results. Any help would be greatly appreciated!

1 ACCEPTED SOLUTION

Hi @hnguyen76 ,

 

check this out. 

PBIX

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


View solution in original post

4 REPLIES 4

Hi @hnguyen76 ,

 

1. Transpose Table

20200409_01.png

2. Replace Values with Header Names

20200409_02.png

3. Use First Row as Header

20200409_03.png

4. Mark the ID Columns and Unpivot Columns

20200409_04.png

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Hi @mwegener ,

I just tried it with the sample example and it seems to be working. My dataset has one more column and row than the sample example.

I need to transform this:

Column1Column2Column3Column4Column5Column6
  2019202020202020
  12123
  YTDPeriodPeriodPeriod
ID203TECH1000101010151020
ID205TECH500550600650
ID203SAM2000201020152040
ID205SAM100011001200

1300

 


Into this:

YearMonthTypeKeyLevel1Value
201912YTDID203TECH1000
201912YTDID205TECH500
201912YTDID203SAM2000
201912YTDID205SAM1000
20201PeriodID203TECH1010
20201PeriodID205TECH550
20201PeriodID203SAM2010
20201PeriodID205SAM1100
20202PeriodID203TECH1015
20202PeriodID205TECH600
20202PeriodID203TECH2015
20202PeriodID205TECH1200
20203PeriodID203SAM1020
20203PeriodID205SAM650
20203PeriodID203SAM2040
20203PeriodID205SAM1300

 

I can't seem to make it work as this is the result I'm getting from your steps:

YearMonthPeriodAttributeValue
   ID203TECH
   ID205TECH
   ID203_1SAM
   ID205_2SAM
201912YTDID2031000
201912YTDID205500
201912YTDID203_12000
201912YTDID205_21000
20201PeriodID2031010
20201PeriodID205550
20201PeriodID203_12010
20201PeriodID205_21100
20202PeriodID2031015
20202PeriodID205600
20202PeriodID203_12015
20202PeriodID205_21200
20203PeriodID2031020
20203PeriodID205650
20203PeriodID203_12040
20203PeriodID205_21300

Hi @hnguyen76 ,

 

check this out. 

PBIX

 

Did I answer your question?
Please mark my post as solution, this will also help others.
Please give Kudos for support.

Marcus Wegener works as Full Stack Power BI Engineer at BI or DIE.
His mission is clear: "Get the most out of data, with Power BI."
twitter - LinkedIn - YouTube - website - podcast


Dang it. I had done this before. Totally forgot about it. Thanks @mwegener it worked! Sending you virtual hugs!

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.