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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Pivot/Unpivot Power Query

Hello I have my source in a similar format as the picture below;

PBI.PNG

The format that I want to switch this to is have the months in one column and have 2 seperate columns for 2018 and 2019 sales.

 

Thanks in advance

3 REPLIES 3
Riantilo
Frequent Visitor

Hi,

In my opinion its always better to transform the input table to row level and use visuals to get de desired result. I made a sample .pbix with both the transformation to row level and the desired table. U can download the file here:  https://we.tl/t-PfxLo5Av6T. 


To get to the row level I first Transposed the table. Then I removed 'Sales' from the year column (not necessary). Ater that I Promoted the first row to headers and renamed them. After that I selected the product columns and unpivoted them to get to row level ('Convert to Rows' table in file).  Within the report I made a Matix that shows the desired result.

 

To get the result using Power Query after the row level there is one more stap ('Option 2' table in file). That is to select the Year column and then choose Pivot and select 'sales' as Value Column. By default the Aggregate function is SUM.

Hope this is useful.

Gr,

Jesse

v-xicai
Community Support
Community Support

Hi,

 

You can unpivot the column 2018 1 sales - 2019 12 sales to row data like picture below. Renamed the new column .Or could you please share your sample data or desired output screenshots for further analysis? You can also upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

For example:

4.png6.png

Best Regards,

Amy

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Thank you for the help,

Yeah I realized I wasn't very clear with my question.  Basically I have different monthly data in columns like 2018 Jan sales, 2018 Feb sales, ... 2019 Jan sales, 2019 Feb sales, ... and I wanna have the months in one column and have 2 columns for 2018 sales and 2019 sales like this;

pbiq.jpg

I tried to unpivot the first 12 column and then the other 12 column but it doesnt work.

 

Thanks again

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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