Forum

Custom Column with ...
 
Notifications
Clear all

Custom Column with Repeating Months and Also Consolidate

8 Posts
2 Users
0 Reactions
200 Views
(@florence)
Posts: 4
Active Member
Topic starter
 

Hello! I am very much in need assistance with the final few steps needed for my query.

Part 1: In my sample data, there are monthly amounts currently listed on 3 columns that are 4 months deep. The formatting is JAN/APR/JUL/OCT, FEB/MAY/AUG/NOV, and MAR/JUN/SEP/DEC, so the data should be read as: Jan, Feb, Mar, <next line> Apr, May, June <next line> July, August, Sept <next line> Oct, Nov, Dec. What I would like to do is to create 3 new columns beside each of the monthly columns that says what month each row of data is.

Part 2: I would like to consolidate all the months on one row, and all of the corresponding amounts on one row as well, instead of 6 columns total.

I've attached screenshots and a sample workbook for your review. Thank you VERY MUCH in advance. I very much appreciate it!

 
Posted : 31/08/2020 1:31 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Florence,

Welcome to the forum.  Your attachments did not attach, did you click on the 'Start Upload' button?

Please see here for (video) instructions on attaching files

https://www.myonlinetraininghub.com/excel-forum/forum-rules-and-guides/read-this-first

It sounds like your data isn't in the correct tabular format needed to work properly with Power Query. You should have a column called month and the months listed in that, not a column for every month.

If you can please reattach your files I'll take a look.

Regards

Phil

 
Posted : 31/08/2020 7:37 pm
(@florence)
Posts: 4
Active Member
Topic starter
 

Oh goodness, I'm sorry! I must've hit Submit without clicking Start Upload. I'll attach them now!

And yes, I'm sure my tabular format is off somewhere. Unfortunately, the text file reports are generated in that format, and for the life of me, I cannot figure out how to fix it in power Part-1-1.pngPart-2-1.pngquery. :/

 
Posted : 01/09/2020 7:33 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Florence,

Can you please supply some sample source files for your query to load?

Phil

 
Posted : 01/09/2020 8:12 am
(@florence)
Posts: 4
Active Member
Topic starter
 

Yes, sir! Here are 2 sample annual reports. The data has been significantly shortened on both, but I did retain the format of how the report is populated.

Thank you so very much for your help!

 
Posted : 02/09/2020 1:40 am
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

Hi Florence,

That data dump is in a really bad format for working with!  I'm sure it's not you fault but it would make lives so much easier if data exports were laid out in a helpful way.  Then again,I guess that's why we need Power Query.

Please have a look at the attached file.

I've added some extra queries to the query you created and have then appended them together to make a final query giving the amounts by month for each Acct Number/Title.  The resulting table is on the sheet 'Appended Queries'.

I haven't done anything with the values for QTD and YTD but assume they can be treated in the same way as the monthly values.

To get this final table I've taken the output from your '948' query and then using the Index column used Number.Mod to add a new column with the month names where they should be.  Repeat this for the other 2 month columns and then by appending the whole lot back together you should get what you are after?

I also started from scratch with my own query which you'll see in the MOTH Query Group in the PQ Editor. Because there are no delimiting characters in the source files, I've had to import using fixed width which will break if the width of the columns in the source files is changed.

It's the same idea though.  Create an Index column then use that to create columns for the months,and QTD and YTD, then append the queries to get your final table which is on the sheet 'MOTH'.

Hopefully this is what you are after.

For these queries to work you'll need to change the path to the source files in the relevant queries.

Regards

Phil

 
Posted : 07/09/2020 11:17 pm
(@florence)
Posts: 4
Active Member
Topic starter
 

I feel some vindication then that this data was really hard to work with. I was starting to feel bonkers! Thanks so much for taking a look at the reports, Phil--this is what I was looking for. Very much appreciate it!

 
Posted : 08/09/2020 11:51 pm
Philip Treacy
(@philipt)
Posts: 1629
Member Admin
 

No worries.

If there were prizes for badly formatted data exports then we'd have a contender.

Phil

 
Posted : 09/09/2020 12:46 am
Share: