web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Stock application with...
Power Apps
Unanswered

Stock application with addressing

(0) ShareShare
ReportReport
Posted on by 33

Hello everyone.
I made an inventory management app. Basically, it works with an Excel spreadsheet on my disk.
He is just working to query, add and subtract the stock balance. However, I wish I had, when adding or subtracting the product, to have the option to choose the address where I want to add or subtract.

If I'm going to add, I need to put the address. So, for a given product, I have "X" units at the "Y" address. And when subtracting, I want to subtract the "Y" address or "Z" adress.

 

LIKETHIS.png

Categories:
I have the same question (0)
  • ilton Profile Picture
    194 on at

    Ola! @gabrielrosa94 

    como registas a entrada e saída? tens um modelo a parte e o stock subtrai deste modelo ou removes autmaticamente no stock?

  • gabrielrosa94 Profile Picture
    33 on at

    AAAAAAA.png

    Eu uso duas tabelas, uma de PRODUTOS e outra de MOVIMENTAÇÕES.

    O saldo do estoque fica na tabela de PRODUTOS. 

    Esse saldo é preenchido conforme um formulário no aplicativo. 

    A outra tabela registra as movimentações. 

     

    AS2.png

     

    No formulário, no campo quantidade, no "ONCHANGE" ele cria uma variável que soma o estoque do produto que tá sendo selecionado ao o que o usuário digitar neste campo. Depois ele compara o código do produto selecionado com o código que está na primeira tabela, pra então, atualizar com o valor da "variável estoque". 

     

    ASAS.png

  • v-yutliu-msft Profile Picture
    Microsoft Employee on at

    Hi @gabrielrosa94 ,

    Here's my understanding about your issue, am I right?

    1)you have two tables, one for product, one for movements

    2)in product table, you have a field named QtddEst which is used to record one product's total number

    3)in movements table, you have a field named Quantidate which is used to record the product number of one movement

    4)if you change one value or add one record in movements table , the product's total number in product table will change

     

    I've made a similar test based on my assumption for your reference:

    1)set gallery1's Items:

    product

    //to display product table

    2)set gallery2's Items:

    Filter(movements,CodProduto=Gallery1.Selected.Codigo)

    //filter movements table based on selected product's codigo in gallery1

    3)in form1

    set Form1's data source:

    movements

    set Form1's Item:

    Gallery2.Selected

    //to edit product number of one movement

    set Quantidate textinput's OnChange:

    Set(var1,Gallery2.Selected.Quantidate);
    Set(var2,Value(DataCardValue7.Text))

    //var1 is the original product number of this movement, var2 is the new product number of this movement

    set form1's OnSuccess:

    Patch(product,Gallery1.Selected,{QtddEst:QtddEst-var1+var2})

     

    Then after you submit Form1, movements table will update its value, product table's total product number will change together too.

     

    Sorry that I'm unfamiliar with Portuguese, so some of my field names, table names are not right, please correct them.

     

     

    Best regards,

  • ilton Profile Picture
    194 on at

    Hi! @gabrielrosa94 

    I sounds to me like you need a 3rd table "Stock in address", so you can register a product stock in a specific location.

    this way you maintain most of the apps structure and the movment can operate in the stock in address.

     

    UpdateIf(stockInAddress, And(codigo = selectedProductCode, Endereço = SelectedAdress),{QtddEst: QtddEst + MovedValue});
    // is this operation is successfull you can update the stock
    UpdateIf(product, And(codigo = selectedProductCode),{QtddEst: QtddEst + MovedValue});

     

    Let me know if this works for you 

  • gabrielrosa94 Profile Picture
    33 on at

    Hey, @v-yutliu-msft 

     

    Thanks for your support.

     

    set Form1's data source:

     

     

    movements

     

     

    **I Can't edit my movements entries. They are  historical records. Maybe I could have a new table for all the ADRESS.

     

    2)set gallery2's Items:

     

     

    Filter(movements,CodProduto=Gallery1.Selected.Codigo)

     

     

    I just can see/chosse products that had a movement. What About the other entries wich  i'll insert their 1s movement? 

     

    Can you help me??

     

    Best Regards.

  • gabrielrosa94 Profile Picture
    33 on at

    I sounds to me like you need a 3rd table "Stock in address", so you can register a product stock in a specific location.

    YES!

    But help me with this: @ilton 

     

    UpdateIf(stockInAddress, And(codigo = selectedProductCode, Endereço = SelectedAdress),{QtddEst: QtddEst + MovedValue}); //WHAT IF MY CODIGO VALUE DOESN'T EXISTS IN MY "STOCKINADRESS" TABLE?(IT'S WHEN MY PRODUCT DIDN'T HAD AN ENTRY) AND WHAT IF MY CODE WHERE = SELECTEDPRODUCTCODE BUT NOT MY ENDEREÇO? (IT MEANS I'M INSERTING THE SAME CODE BUT IN ANOTHER ADRESS)
    // is this operation is successfull you can update the stock
    UpdateIf(product, And(codigo = selectedProductCode),{QtddEst: QtddEst + MovedValue});

     

     

  • ilton Profile Picture
    194 on at

    Hi! @gabrielrosa94 

    sorry for my absence, I was having network issues

    I was thinking about 3 tables

    as in the attachments

    Products (Yellow) - StockInAddress (Blue) - Movment (Green)

    assuming the app operation are:

    1. Register a product and this part is working 

    2. add/remove to the product stock providing the address

     

    // assuming the pruduct exixts in the first table and the selected address is valid
    //1. check if the product exists in the stock
    If(
     // true if the product is not registered for this address in the StockInAddress table
     IsBlank(LookUp(StockInAddress, And(cod = SelectedCode, address = selectedAddress))),
     Patch(StockInAddress, Defaults(StockInAddress), {cod: SelectedCode, address: selectedAddress, stock: 0})
    );
    If(
     // notify incase of removing, if the stock is less than the amount we want to remove
     And(
     selectedTipoDeMoviment = "saida", 
     LookUp(StockInAddress, 
     AND(
     cod = SelectedCode, 
     address = selectedAddress
     )
     ).stock < selectedAmount
     ),
     Notify("algum aviso de stock baixo", NotificationType.error)
    );
    // This will register the movement as a new record in the interest of keeping record of movements
    Patch(Movement, Defaults(Movement), {cod: selectedCode, dataDeMovimento: selectedDataDeMovimento, tipoDeMoimento: selectedTipoDeMoviemnto, address: selectedAddress, qtd: selectedQtd});
    
    // updates StockInAddress
    UpdateIf(StockInAddress, And(cod = SelectedCode, address = selectedAddress), {stock: stock + If(tipoDeMovimento = "entrada", selectedQtd, -SelectedQtd)});
    // updates the products stock
    UpdateIf(product, And(cod = SelectedCode), {stock: stock + If(tipoDeMovimento = "entrada", selectedQtd, -SelectedQtd)})

     

    Tip

    1. if you use positive/negative number to indicate entrada/saída, it will help with operations ex. instead of Sum(Filter(entrada..)) - Sum(Filter(saidas...)) you would have Sum(all...).

    instead of If(tipoDeMovimento = "entrada", selectedQtd, -SelectedQtd) you would hae SelectedQtd

     

    Feel free to reach out if you need to.

    Annotation 2020-04-03 232812.png

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 883

#2
Valantis Profile Picture

Valantis 571

#3
11manish Profile Picture

11manish 477

Last 30 days Overall leaderboard