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
LEC
Frequent Visitor

Pivoting

I'm sure this has been asked, but I'm still struggling to make the data pivot in the way that I want it to.

 

I have a query connected to Power BI with data pulling back by week since 2016, like the following:

 

Year         Week          Sales        Inventory

2016         1                 100         200

2016         2                  104        208

....

2017         1                 132         294

2017         2                 88          105

........

 

I'd like to be able to pivot the table to line up like this:

 

Week          2016 Sales    2017 Sales   2016 Inventory   2017 Inventory

1                  100               132              200                     294

2                  104                88                208                    105

 

Anyone have advice?

1 ACCEPTED SOLUTION
Sean
Community Champion
Community Champion

@LEC

In the Query Editor...

1) Unpivot Sales & Inventory

2) Merge Year and Atrribute

3) Pivot the Merged Column (Don't Aggregate)

As shown here...

Query Editor - Unpivot, Merge & Pivot.gif

Hope this helps! Smiley Happy

View solution in original post

1 REPLY 1
Sean
Community Champion
Community Champion

@LEC

In the Query Editor...

1) Unpivot Sales & Inventory

2) Merge Year and Atrribute

3) Pivot the Merged Column (Don't Aggregate)

As shown here...

Query Editor - Unpivot, Merge & Pivot.gif

Hope this helps! Smiley Happy

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.