• 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

PowerQuery: Calculate Aging Buckets|Power Query|Excel Forum|My Online Training Hub

You are here: Home / PowerQuery: Calculate Aging Buckets|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 QueryPowerQuery: Calculate Aging Buckets
sp_PrintTopic sp_TopicIcon
PowerQuery: Calculate Aging Buckets
Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
1
September 28, 2022 - 7:21 am
sp_Permalink sp_Print

Hi All,

 

Hopefully you can help.

This file contains 3 sheets. 

PowerQuery - This contains just a link to the Source sheet

Againg Table - Just showing you how we group the data together.

Source:  This is just the source data that will be linked to an extract in a folder.

What we want to do is use PowerQuery to bring data that is in a folder which I have the skills to do LOL :).  A sample of that is in the Source sheet between A:H.  Column I J and K is just what we use today without PowerQuery to calculate our buckets.  Esentially we will bring the file in through PowerQuery and want to add some logic to add these aging buckets based off the logic.  Today Date which can be a manual entry - Contact Date.  

 

Can someone please help me creating the logic to create these buckets so that when we bring in the new file it automatically creates these bucket namethe Age of Encounters.  So it would be the days outstanding and then the actual bucket.  As seen in Source sheet Column J and K.

 

48 Hrs Open
4-5 Days
6-13 Days
14-27 Days
28-55 Days
56-111 Days
112-223 Days
224-364 Days
365+ Days

 

Thank you kindly for reading.

Avatar
Philip Treacy
Admin
Level 10
Forum Posts: 1514
Member Since:
October 5, 2010
sp_UserOfflineSmall Offline
2
September 28, 2022 - 8:50 am
sp_Permalink sp_Print

Hi Steven,

No file is attached. You have to click the Upload button to load the file.

Read This First | Forum Rules and Guides | Excel Forum • My Online Training Hub

Regards

Phil

Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
3
September 28, 2022 - 10:27 pm
sp_Permalink sp_Print sp_EditHistory

My apologies.  Let me try again.

 

Excel Version:

Microsoft® Excel® for Microsoft 365 MSO (Version 2202 Build 16.0.14931.20704) 64-bit

Avatar
Jessica Stewart
Northern USA
Member
Members


Trusted Members
Level 0
Forum Posts: 202
Member Since:
February 13, 2021
sp_UserOnlineSmall Online
4
September 29, 2022 - 3:27 am
sp_Permalink sp_Print

Hi Steven!

Is this what you're looking for? 🙂

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 440
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
5
September 29, 2022 - 3:39 pm
sp_Permalink sp_Print

As a variant, please see the attached file. Same end result as Jessica. Different method. I thought is was easier to prepare the bucket list in Excel and use the Append option in PQ, rather than multiple Merge steps.

Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
6
September 30, 2022 - 3:52 am
sp_Permalink sp_Print sp_EditHistory

Thank you so much for taking the time out of your day to help me. 

Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
7
October 2, 2022 - 10:23 pm
sp_Permalink sp_Print sp_EditHistory

Riny, I applied your solution but I just realized that I will have problems in the future, not with the solution provided, but with my process.  

The issue I belive I will run into is keeping the aging date static.  Right now my logic is to get (todays date -  contact date).  If I do this from week to week the date will change and the aging buckets will move for all of the files.  I do not want that, I only want the aging buckets to be frozen in time  Is there a way to replace my logic to grab File Create Date instead of Todays Date?  I think If I implement the file create date I will be able to accurately calculate my age buckets and will be frozen in time.  I just dont know how to dynamically add the file create date as I keep on adding these weekly files.

What I need to do is have 2 queries, the first one would be to grab just the current week file and the second query will start to aggregate all of the weekly files toghether, with the static logic, so we can perform trending.

 

I hope I am making sense.

Thank you for reading.

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 440
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
8
October 2, 2022 - 11:29 pm
sp_Permalink sp_Print

If you connect to Files From a Folder,  you will see an overview of all files in the folder with the following columns (screenshot below):

Screenshot-2022-10-02-145329.pngImage Enlarger

Note the "Date created" column. Remove all columns except Content and Date created, and press the arrowed button in the Content column and select the table you want to import. That should create a bunch of Applied steps, one of which is labeled "Invoke Custom Function". Remove all of the next steps. Now you have a table with three columns (Contents, Date Created and Transform File). Get rid of the Content column and expand the Transform File column. 

The resulting table will look like this. Note that you have the creation data in the first column which you can use, in stead of today's date, to calculate the ageing (Date created minus Contact date).

Screenshot-2022-10-02-152150.pngImage Enlarger

sp_PlupAttachments Attachments
  • sp_PlupImage Screenshot-2022-10-02-145329.png (12 KB)
  • sp_PlupImage Screenshot-2022-10-02-152150.png (66 KB)
Avatar
Steven Vaughan
Member
Members
Level 0
Forum Posts: 12
Member Since:
January 5, 2022
sp_UserOfflineSmall Offline
9
October 3, 2022 - 1:26 am
sp_Permalink sp_Print

Hi Riny, May I please ask one more question. 

I would like to create a count through the following logic.  If Age of Account is greater than 5 days then add a column with a numerical value of 1.  If its less than or equal to 5 then leave blank.  What I would like to do is identify how many accounts are over 5 days old.

 

Thank you gain.

Avatar
Riny van Eekelen
Örnsköldsvik, Sweden
Moderator
Members


Trusted Members

Moderators

Power BI
Level 0
Forum Posts: 440
Member Since:
January 31, 2022
sp_UserOfflineSmall Offline
10
October 3, 2022 - 4:51 am
sp_Permalink sp_Print

You can add a custom column with the following code:

= if [Age of Encounters] > 5 then 1 else null
 
That adds a column with ones and nulls. 
sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Aislinn Mellamphy, Lynnette Altomari, Jessica Stewart, Roy Lutke, Dieneba NDIAYE, Jeff Krueger, Darrell Hodge, Tucker Oakley, Natasha Smith
Guest(s) 11
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:
Sopi Yuniarti
sandra parker
LAFONSO HERNANDEZ
Hayden Hao
Angela chen
Sean Moore
John Chisholm
vexokeb sdfg
John Jack
Malcolm Toy
Forum Stats:
Groups: 3
Forums: 24
Topics: 6214
Posts: 27243

 

Member Stats:
Guest Posters: 49
Members: 31894
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.