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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
arolon2
Frequent Visitor

Importing data with based on rolling set of months

Hello,

 

I have folder with years of excel reports that provide estimate projections 24 months into the future for specific items. I would like to mass import them but understand the difficulties due to the the column headers changing over time. I could import the report one at a time and unpivot the months colunms but that is too cumbersome. Is Power Query able to automate this unpivot step so that the data can be combined when bringing in the folder of reports?

7 REPLIES 7
amitchandak
Super User
Super User

@arolon2 , once you define steps in power query they should repeat with new data load.

https://radacad.com/pivot-and-unpivot-with-power-bi
Transpose : https://yodalearning.com/tutorials/power-query-helps-transposing-data/

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

That's where I'm stuck. If I try to import the folder in Power query not all the data is imported due to column header mismatching. I am unsure how to have the unpivot step happen as the data is brought in to the model.

Hi @arolon2 ,

 

" If I try to import the folder in Power query not all the data is imported due to column header mismatching. "

Like this?

v-lionel-msft_0-1596696638604.png

v-lionel-msft_1-1596696653240.png

v-lionel-msft_2-1596696695531.png

You may need to modify the column headings in the data source and then import the folder.

 

Best regards,
Lionel Chen

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

 

 

Let me provide my own visual for better explination. For example I have a report that shows the following:

ItemItem DescItem FamilyFebMarAprMay
StuffStuffStuff####

 

The # are future projection, the report is ran each month so next period it appears like so:

ItemItem DescItem FamilyMarAprMayJun
StuffStuffStuff####

 

What I am looking for is to combine the reports but as the column headers change an error gets tripped. I could import,  unpivot the table to look as follows, then append... but that would be too cumbersome. 

 

ItemItem DescItem FamilyMonthValue
StuffStuffStuffMar#
StuffStuffStuffApr#
StuffStuffStuffMay#
StuffStuffStuffJune#

 

How do I get power query to do this unpivot step in the "sample file" step of importing?

Hi @arolon2 ,

 

You can create a matrix visual and add [Month] to the ‘Column’ label.

 

Best regards,
Lionel Chen

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

Hi @arolon2 

 

For Unpivoting part -

1). Go to powerquery and select first four columns (item, item,desc,family etc) and don't touch month columns.

2). Go to Transform tab in the toolbar -->  when you click 'Unpivot Columns' dropdown , choose second option "Unpivot Other columns" I think this will solve the issue when new months get added to the data.

Please let me know if above helps.

I guess you will have just one file at the end right, you dont require to combine the multiple excel files, right?

Did you select Combine & Transform to combine all the files?  If so, there will be a Transform Sample File query (and an associated function).  If not already, you could do an Unpivot Other Columns step in that (assuming the columns not unpivotted are the same), so that when combine they all have Attribute/Value (or whatever you call the two columns from the unpivot step).

 

If needed, you can also use the approach shown here to dynamically change column names based on column # vs the actual names.  The video is in Power Query in Excel, but the approach/syntax is the same.

https://www.youtube.com/watch?v=yBJr0sAc-m4

 

If this works for you, please mark it as the solution.  Kudos are appreciated too.  Please let me know if not.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.