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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Not applicable

Pivot/Unpivot Power Query

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


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

Frequent Visitor


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: 

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.



Community Support
Community Support



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:


Best Regards,



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

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;


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


Thanks again

Helpful resources

Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

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

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.

Top Solution Authors