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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Amar-Agnihotri
Resolver I
Resolver I

How to get data in pivot table format from multiple excel sheets using Power Query?

Hi All,

I am having 5 excel files Sales_2017, Sales_2018, Sales_2019, Sales_2020,Sales_2021 and each excel is having this format of data 

AmarAgnihotri_0-1658586457553.png

 

The customer Name may be same in any of the files and may be different and also it is possible that sopme customer are not present in any other files. 

 

I want this format of data 

AmarAgnihotri_1-1658586544203.png

 

The values in 2017, 2018, 2019, 2020, 2021 are the agregated sum of values present in each excel column.

For the customer who is not present in other years there will be null or blank.
First of All, I created a unique customer name table having all the customer names in that . I want to use this table as a Dimension Table. 

AmarAgnihotri_2-1658586704897.png

Now i used merge between this new customer table with each of Sales table to get this format of data

 

AmarAgnihotri_3-1658586787266.png

I used the below join 

AmarAgnihotri_4-1658586813206.png

So i performed 5 joins with each of the sales table to get these 5 tables 

AmarAgnihotri_5-1658586859183.png

 

AmarAgnihotri_6-1658586873006.png

 

AmarAgnihotri_7-1658586888115.png

 

AmarAgnihotri_8-1658586900238.png

 

AmarAgnihotri_9-1658586917227.png

 

Till here the data is coming correctly. But now i am stuck to moved ahead. I am confused about what to perform now to get the below format -

AmarAgnihotri_10-1658586984133.png

 

If i perform join again between the above tables that i created then this will create multiple duplicate values in the table. We can't perform left outer join because it will loose those customer from the right table which are not in the left one. Same with the right join and if i perform full outer a lot of duplicates are bein created and we can't remove the duplicates from the final table because my source table is containing same customer multiple times with different sales values in the same year as shown 

This is the source table Sales_2017 having multiple entries for the same customer 

AmarAgnihotri_11-1658587217421.png

Please suggest how to achieve the requirement

 

 

 

 

 



 

 

1 ACCEPTED SOLUTION
KT_Bsmart2gethe
Impactful Individual
Impactful Individual

Hi @Amar-Agnihotri ,

 

Step1 - Append all five files.

Step2 - Unpivot all the value columns (i.e. 2017 - 2021). You will get "Attribute" and "Value" columns

Step3 - Pivot the "Attribute" column

 

Regards

KT

View solution in original post

2 REPLIES 2
Amar-Agnihotri
Resolver I
Resolver I

@KT_Bsmart2gethe Thanks a lot. You saved my time finally 🙂

KT_Bsmart2gethe
Impactful Individual
Impactful Individual

Hi @Amar-Agnihotri ,

 

Step1 - Append all five files.

Step2 - Unpivot all the value columns (i.e. 2017 - 2021). You will get "Attribute" and "Value" columns

Step3 - Pivot the "Attribute" column

 

Regards

KT

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors