Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
reynaldo_malave
Helper III
Helper III

Inventory Repostion for Picking

Hi guys,

 

I been stuck on this for a couple of days now. Using power query I am working on a picking line inventory restocking. The whole idea is to get products on the picking line on certain order.

 

This is my original table :

ProductoIdAvailableRestockingNeed
11150160
11

1200

160
112500160

 

This is what i am looking for: 

 

ProductoIdAvailableRestockingRestock
11150160150
1112001010
112500null 

 

I am looking to get back the Restock column.

 

I any of you can help out here it would be great. 

 

I have been trying to adapt the solution

 

thanks.

 

Reynaldo

1 ACCEPTED SOLUTION
AlienSx
Super User
Super User

hi, @reynaldo_malave try this

let
    Source = your_table,
    recs = List.Buffer(Table.ToRecords(Source)),
    count = List.Count(recs),
    g = 
        List.Generate(
            () => 
                [i = 0, 
                Productold = recs{0}[ProductoId], 
                Available = recs{0}[Available], 
                Restocking = recs{0}[RestockingNeed], 
                Restock = List.Min({Restocking, Available})],
            (x) => x[i] < count,
            (x) => 
                [i = x[i] + 1,
                Productold = recs{i}[ProductoId],
                Available = recs{i}[Available],
                Restocking = List.Max({0, x[Restocking] - x[Restock]}),
                Restock = List.Min({Available, Restocking})]
        ),
    z = Table.RemoveColumns(Table.FromRecords(g), {"i"})
in
    z

 

View solution in original post

2 REPLIES 2
AlienSx
Super User
Super User

hi, @reynaldo_malave try this

let
    Source = your_table,
    recs = List.Buffer(Table.ToRecords(Source)),
    count = List.Count(recs),
    g = 
        List.Generate(
            () => 
                [i = 0, 
                Productold = recs{0}[ProductoId], 
                Available = recs{0}[Available], 
                Restocking = recs{0}[RestockingNeed], 
                Restock = List.Min({Restocking, Available})],
            (x) => x[i] < count,
            (x) => 
                [i = x[i] + 1,
                Productold = recs{i}[ProductoId],
                Available = recs{i}[Available],
                Restocking = List.Max({0, x[Restocking] - x[Restock]}),
                Restock = List.Min({Available, Restocking})]
        ),
    z = Table.RemoveColumns(Table.FromRecords(g), {"i"})
in
    z

 

Thanks @AlienSx  this worked like a charm 🙂

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors