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

Pivoting multiple files into one

Hi everyone,

I am facing a challenge right now.

I need to combine various CSV into one database. The "catch" is:

1. The files have the columns as rows;

2. The files may have different number of rows (columns).

Here is an example below:

File1

Agent Name,xpto1
Agent Email,xpto1@abcd.com
Date,04/18/2019 14:58:25
Time Zone,Europe/Lisbon
Time Filter Begin,04/17/2019 00:00:00
Time Filter End,04/17/2019 23:00:00
Total Unavailable Time (hh:mm:ss),00:00:00
Total Offline Time (hh:mm:ss),00:47:50

File2

Agent Name,xpto2
Agent Email,xpto2@abcd.com
Date,04/18/2019 14:58:25
Time Zone,Europe/Lisbon
Time Filter Begin,04/17/2019 00:00:00
Time Filter End,04/17/2019 23:00:00
Total Auto Answered Calls Notifications Offered,27
Total Number of Calls Notification Offered,42
Total Auto Answered Calls Connected,15
Total Number of Calls Connected,15
Total Number of Multicast Call Notifications Offered,15
Total Unavailable Time (hh:mm:ss),00:02:32
Total Offline Time (hh:mm:ss),14:54:48
Total Wrap-up Time (hh:mm:ss),01:40:37
Total Email Time (hh:mm:ss),00:42:50
Total In-call Time (hh:mm:ss),03:57:42
Total Available Time (hh:mm:ss),01:04:56
Total Meal Time (hh:mm:ss),01:00:59
Total Break Time (hh:mm:ss),00:35:39

Basically I need to combine a hundred (give or take) of these files in a database format

Column 1, Column2, etc, with the correspondent values below each column, with nulls/zeros in case some file does not have a row that other may have.

Any clue how to do this?

I've tried to pivot all the files after merging but I am getting an error:

"Expression.Error: There were too many elements in the enumeration to complete the operation.
Details:
List"

Thanks in advance!

1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@FredPereira See attached, I have created 2 sample tables file1 and file2, look at file1 which is pivoted. Key here is to add unique identifier for each table before pivot. I added index column in both files which work as unique identifier, you can call that index column anything, with any value but it need to be unique for each file.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

3 REPLIES 3
parry2k
Super User
Super User

@FredPereira See attached, I have created 2 sample tables file1 and file2, look at file1 which is pivoted. Key here is to add unique identifier for each table before pivot. I added index column in both files which work as unique identifier, you can call that index column anything, with any value but it need to be unique for each file.

 

 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Forgot to mention an important detail.

I am linked to a folder, so I am merging all the files that way. So everyday, around 50 files are downloaded and inserted in said folder everyday.

The idea is to have my database updating automatically just by adding files to the folder.

Will the index column be feasible in this scenario?

Thank you very much for the response!

 

@FredPereira yes it is even better, basically the way you want to think is to have a column with unique value in it for each file, in case of folder, you can surely have filename as unique or create one. I think it is easier and solution I provided would work.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

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.