• Skip to main content
  • Skip to header right navigation
  • Skip to site footer

My Online Training Hub

Learn Dashboards, Excel, Power BI, Power Query, Power Pivot

  • Courses
  • Pricing
    • Free Courses
    • Power BI Course
    • Excel Power Query Course
    • Power Pivot and DAX Course
    • Excel Dashboard Course
    • Excel PivotTable Course – Quick Start
    • Advanced Excel Formulas Course
    • Excel Expert Advanced Excel Training
    • Excel Tables Course
    • Excel, Word, Outlook
    • Financial Modelling Course
    • Excel PivotTable Course
    • Excel for Customer Service Professionals
    • Excel for Operations Management Course
    • Excel for Decision Making Under Uncertainty Course
    • Excel for Finance Course
    • Excel Analysis ToolPak Course
    • Multi-User Pricing
  • Resources
    • Free Downloads
    • Excel Functions Explained
    • Excel Formulas
    • Excel Add-ins
    • IF Function
      • Excel IF Statement Explained
      • Excel IF AND OR Functions
      • IF Formula Builder
    • Time & Dates in Excel
      • Excel Date & Time
      • Calculating Time in Excel
      • Excel Time Calculation Tricks
      • Excel Date and Time Formatting
    • Excel Keyboard Shortcuts
    • Excel Custom Number Format Guide
    • Pivot Tables Guide
    • VLOOKUP Guide
    • ALT Codes
    • Excel VBA & Macros
    • Excel User Forms
    • VBA String Functions
  • Members
    • Login
    • Password Reset
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Custom Column with Repeating Months and Also Consolidate|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Custom Column with Repeating Months and Also Consolidate|Power Query|Excel Forum|My Online Training Hub
Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search|Last Search Results
Search
Forum Scope




Match



Forum Options



Minimum search word length is 3 characters - maximum search word length is 84 characters
sp_Search Search
sp_RankInfo
Lost password?
sp_CrumbsHome HomeExcel ForumPower QueryCustom Column with Repeating Months…
sp_PrintTopic sp_TopicIcon
Custom Column with Repeating Months and Also Consolidate
Avatar
b_flo

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
August 31, 2020
sp_UserOfflineSmall Offline
1
August 31, 2020 - 3:31 am
sp_Permalink sp_Print

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!

sp_AnswersTopicSeeAnswer See Answer
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
August 31, 2020 - 9:37 am
sp_Permalink sp_Print

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.myonlinetraininghu.....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

Avatar
b_flo

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
August 31, 2020
sp_UserOfflineSmall Offline
3
August 31, 2020 - 9:33 pm
sp_Permalink sp_Print

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.pngImage Enlarger

Part-2-1.pngImage Enlarger
query. :/

sp_PlupAttachments Attachments
  • sp_PlupImage Part-1-1.png (176 KB)
  • sp_PlupImage Part-2-1.png (211 KB)
Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
4
August 31, 2020 - 10:12 pm
sp_Permalink sp_Print

Hi Florence,

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

Phil

Avatar
b_flo

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
August 31, 2020
sp_UserOfflineSmall Offline
5
September 1, 2020 - 3:40 pm
sp_Permalink sp_Print

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!

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
6
September 7, 2020 - 1:17 pm
sp_Permalink sp_Print sp_EditHistory

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

sp_AnswersTopicAnswer
Answers Post
Avatar
b_flo

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
August 31, 2020
sp_UserOfflineSmall Offline
7
September 8, 2020 - 1:51 pm
sp_Permalink sp_Print

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!

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1515
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
8
September 8, 2020 - 2:46 pm
sp_Permalink sp_Print

No worries.

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

Phil

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Chris Warren, Riny van Eekelen
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 870
Purfleet: 412
Frans Visser: 346
David_Ng: 306
lea cohen: 219
A.Maurizio: 202
Jessica Stewart: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
michael serna
mashal sana
Tiffany Kang
Leah Gillmore
Sopi Yuniarti
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
Forum Stats:
Groups: 3
Forums: 24
Topics: 6214
Posts: 27246

 

Member Stats:
Guest Posters: 49
Members: 31897
Moderators: 3
Admins: 4
Administrators: Mynda Treacy, Philip Treacy, Catalin Bombea, FT
Moderators: MOTH Support, Velouria, Riny van Eekelen
© Simple:Press —sp_Information

Sidebar

Blog Categories

  • Excel
  • Excel Charts
  • Excel Dashboard
  • Excel Formulas
  • Excel PivotTables
  • Excel Shortcuts
  • Excel VBA
  • General Tips
  • Online Training
  • Outlook
  • Power Apps
  • Power Automate
  • Power BI
  • Power Pivot
  • Power Query
microsoft mvp logo
trustpilot excellent rating
Secured by Sucuri Badge
MyOnlineTrainingHub on YouTube Mynda Treacy on Linked In Mynda Treacy on Instagram Mynda Treacy on Twitter Mynda Treacy on Pinterest MyOnlineTrainingHub on Facebook
 

Company

  • About My Online Training Hub
  • Disclosure Statement
  • Frequently Asked Questions
  • Guarantee
  • Privacy Policy
  • Terms & Conditions
  • Testimonials
  • Become an Affiliate

Support

  • Contact
  • Forum
  • Helpdesk - For Technical Issues

Copyright © 2023 · My Online Training Hub · All Rights Reserved. Microsoft and the Microsoft Office logo are trademarks or registered trademarks of Microsoft Corporation in the United States and/or other countries. Product names, logos, brands, and other trademarks featured or referred to within this website are the property of their respective trademark holders.