Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Given Maximum Qty in a pallet is 20.
I would like to created a loop in power query where by when each row is added downward and when the sum qty is more than 20 , the rows should be group (Pallet) and the loop run again.
Example:
Input
| Material | Qty |
| ABC-123 | 10 |
| ABC-124 | 5 |
| ABC-125 | 6 |
| ABC-126 | 4 |
| ABC-127 | 10 |
| ABC-128 | 13 |
| ABC-129 | 15 |
Output
| Material | Qty | Pallet |
| ABC-123 | 10 | 1 |
| ABC-124 | 5 | 1 |
| ABC-125 | 6 | 2 |
| ABC-126 | 4 | 2 |
| ABC-127 | 10 | 2 |
| ABC-128 | 13 | 3 |
| ABC-129 | 15 | 3 |
Solved! Go to Solution.
Hi @Jagen007
Download example file with the calculations shown below
Based on what you've described : when the sum qty is more than 20 the rows should be given the same pallet number.
Based on that, the table would look like this
| Material | Qty | Pallet |
| ABC-123 | 10 | 1 |
| ABC-124 | 5 | 1 |
| ABC-125 | 6 | 2 |
| ABC-126 | 4 | 2 |
| ABC-127 | 10 | 2 |
| ABC-128 | 13 | 3 |
| ABC-129 | 15 | 4 |
To do this you can add an Index column, starting at 1, and use this to create the column
= Number.RoundUp(List.Sum(List.FirstN(#"Added Index"[Qty], [Index]))/20)
Regards
Phil
Proud to be a Super User!
Hi @Jagen007
The code does this:
Regards
Phil
Proud to be a Super User!
Hi @Jagen007
Download example file with the calculations shown below
Based on what you've described : when the sum qty is more than 20 the rows should be given the same pallet number.
Based on that, the table would look like this
| Material | Qty | Pallet |
| ABC-123 | 10 | 1 |
| ABC-124 | 5 | 1 |
| ABC-125 | 6 | 2 |
| ABC-126 | 4 | 2 |
| ABC-127 | 10 | 2 |
| ABC-128 | 13 | 3 |
| ABC-129 | 15 | 4 |
To do this you can add an Index column, starting at 1, and use this to create the column
= Number.RoundUp(List.Sum(List.FirstN(#"Added Index"[Qty], [Index]))/20)
Regards
Phil
Proud to be a Super User!
Hi Philip,
thank you very much for giving the solution as it working but can you please explain the formula/step ?
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.
| User | Count |
|---|---|
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 |
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 5 | |
| 4 |