r/ExcelPowerQuery • u/Ok_Dimension7436 • Jul 08 '25
I really need help with this Power Query...
Hi all
(I’ve whitened out some data as this is company sensitive)
So, the issue i have is that i need to create a ‘simple’ planning on what day we can earliest receive containers at our company with the only rule that we can only receive 15 containers each day.
I took the following steps in Power query:
- What i already did was create an additional column with the first possible delivery date which is just the arrival date at the terminal +1.
- Added a column with an index number.
- Added a column with a batchgroup (grouping containers per 15)
- Then i added a working calendar on which days we are open and can receive the 15 containers.
With these steps i tried to calculate the earliest possible delivery date with the following formula:
= let calendar = WorkingCalendar[WorkingDate], eligibleDates = List.Select(calendar, (d) => d >= [FirstPossibleDate]), deliveryDate = if List.Count(eligibleDates) > Number.IntegerDivide([Index], 15) then eligibleDates{Number.IntegerDivide([Index], 15)} else null in deliveryDate
On first sight this seems to work and it groups the containers to a maximum of 15 containers / day.
But when i take a closer look it does not fill the containers to a maximum of 15 / day and sometimes just skips days or start on a new day when the previous day only has 4 / 15 containers planned when there are others that could be booked on the same date.
I don’t seem to find the solution here... I think i might have to do someting with the first possible date changing and it automatically chooses a new delivery date.
(See example of when it changes to 17/06 when it should be 16/06. And only 1 container on 18/06)
I would really appreciate any help on this!!!


View all comments
Show parent comment
1
u/Ok_Dimension7436 Jul 09 '25
Hi John
Many thanks on your support on this, much appreciated!
Unfortunately the new function returns 'null' on all cases.Which is stranges as there are multiple possible dates...
My PowerQuery Knowlage is not good enough to understand what needs fixing atm...