• 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
  • Blog
  • Excel Webinars
  • Excel Forum
    • Register as Forum Member

Power query - Advanced M-code for allocation|Power Query|Excel Forum|My Online Training Hub

You are here: Home / Power query - Advanced M-code for allocation|Power Query|Excel Forum|My Online Training Hub

vba course banner

Avatar
sp_LogInOut Log In sp_Registration Register
sp_Search Search
Advanced Search
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 QueryPower query - Advanced M-code for a…
sp_PrintTopic sp_TopicIcon
Power query - Advanced M-code for allocation
Avatar
Jan pedersen

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 8, 2021
sp_UserOfflineSmall Offline
1
October 8, 2021 - 10:56 pm
sp_Permalink sp_Print sp_EditHistory

I have a Power query challenge where I need full support on.
I want to allocate incoming purchase deliveries to sales lines which has a shipment priority, so end result will be a weekly shipment plan.

 

Here is a example of input and output:

 

Input table A (about 30K Sales lines, not 30k pcs)

Sales lines 21-123 – Prior.1 – Item A – 400 pcs

Sales lines 21-103 – Prior.2 – Item A – 415 pcs

Sales lines 21-023 – Prior.3 – Item A – 200 pcs

Sales lines 21-125 – Prior.4 – Item A – 350 pcs

 

Input table B (Incoming Purchasing orders.)

Weekly deliveries from Suppliers, due to lack of supplier capacity.

Item A – Week 202143 – 350 pcs

Item A – Week 202144 – 375 pcs

Item A – Week 202145 – 150 pcs

Item A – Week 202147 – 550 pcs

 

Output table C (Please ignore the blank rows below)

Sales lines 21-123 – Prior.1 – Item A – 400 pcs – Shipment 350 pcs – week 202143.    (Incoming Week 202143 – 350 pcs)

Sales lines 21-123 – Prior.1 – Item A – 400 pcs – Shipment 50 pcs – week 202144.      (Incoming Week 202144 – 375 pcs)

 

Sales lines 21-103 – Prior.2 – Item A – 415 pcs – Shipment 325 pcs – week 202144.     (Incoming Week 202144 – 375 pcs)

Sales lines 21-103 – Prior.2 – Item A – 415 pcs – Shipment   95 pcs – week 202145.     (Incoming Week 202145 – 150 pcs)

 

Sales lines 21-023 – Prior.3 – Item A – 200 pcs – Shipment  55 pcs – week 202145.     (Incoming Week 202145 – 150 pcs)

Sales lines 21-023 – Prior.3 – Item A – 200 pcs – Shipment 145 pcs – week 202147.     (Incoming Week 202147 – 550 pcs)

 

Sales lines 21-125 – Prior.4 – Item A – 350 pcs – Shipment 395 pcs – week 202147.     (Incoming Week 202147 – 550 pcs)

 

I have to use the Power Query Excel to solve this challenge as output Table C will be an input to another query

I think the task can be solved by Power Query functions below, but I am not sure and dont how to structure the entire M-code.

 

  • List.generate (Iteration over Table A and use input from Table B , big challenge for me)
  • Running Total in grouped tables https://www.myonlinetraininghu.....ower-query
  • List.Transform({1..[SplitLines]})


Hope you can support on this

Avatar
Anders Sehlstedt
Eskilstuna, Sweden

VIP
Members


Trusted Members
Level 3
Forum Posts: 873
Member Since:
December 7, 2016
sp_UserOfflineSmall Offline
2
October 9, 2021 - 4:33 pm
sp_Permalink sp_Print

Hello Jan,

Welcome to MOTH. If you had read the forum rules you would have noticed that is expected to upload a sample file with relevant data.
You will get better help by doing so, as not many are interested in recreating data to later find out the given solution is wrong due to wrong layout or something similar.

Br,
Anders

Avatar
Jan pedersen

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 8, 2021
sp_UserOfflineSmall Offline
3
October 11, 2021 - 1:59 am
sp_Permalink sp_Print sp_EditHistory

Hi Anders 

Thank you for the feedback 

Sample file - input and expected output

Avatar
Jan pedersen

Active Member
Members
Level 0
Forum Posts: 4
Member Since:
October 8, 2021
sp_UserOfflineSmall Offline
4
October 11, 2021 - 2:13 am
sp_Permalink sp_Print sp_EditHistory

Image Enlarger

Expected outcome = Table C

Please attached image

sp_Feed
Go to top
Forum Timezone: Australia/Brisbane
Most Users Ever Online: 245
Currently Online: Andrew Wilkie, Malcolm Sawyer
Guest(s) 10
Currently Browsing this Page:
1 Guest(s)
Top Posters:
SunnyKow: 1432
Anders Sehlstedt: 873
Purfleet: 414
Frans Visser: 346
David_Ng: 306
lea cohen: 222
Jessica Stewart: 216
A.Maurizio: 202
Aye Mu: 201
jaryszek: 183
Newest Members:
Melanie Ford
Isaac Felbah
Adele Glover
Hitesh Asrani
Rohan Abraham
Anthony van Riessen
Erlinda Eloriaga
Abisola Ogundele
MARTYN STERRY
Rahim Lakhani
Forum Stats:
Groups: 3
Forums: 24
Topics: 6355
Posts: 27792

 

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