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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Shopping cart

(0) ShareShare
ReportReport
Posted on by 19

Even though I just started learning how to build Powerapps, I have made an pretty good app for registering inventory.

Now I don't like to ask for help every time, I always try to search for solutions myself if I'am stuck at something. This works pretty good, but I can't find an solution for this thing (I don't know what to search for exactly though):

 

I have an dropdown list where the user can choose an item and than an input box to fill in the amount for that item.

All items are added to an collection called 'InventoryList'. That gallery is directly shown besides the input part.

The current situation is that, if an item already exists in the gallery, the new amount is put in as an seperate item.
I like to have it so that it add up the amount of the item instead of putting everything in as seperate items, even when that same item is already in the gallery.

 

So basicly, in the current situation: If for example Item1 is already in the gallery, and I add that item again, but whith another amount, I end up with having Item1 two times in the gallery, with two different amounts.

I like to have: If I add Item1 to the gallery, but it already exists, it only add up the amount of that item.


What I have now for the default on the submit button is: 

 

Collect (InventoryList; {Item: I_Item.Selected.Title; Amount: I_Amount.Text; Photo: Filter_dropdown_photo.SelectedText.Value});;

 

And than I have an gallery showing the items in StockList. 

As it is, I'm not writing the records storage location, I just make an collection and than the user can have it send by email at the end of the day, by cliking another button.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @alexanderb1 

    Try changing your formula to the following:

    With({lclItem:Lookup(InventoryList; Item=I_Item.Selected.Title)};
     If(IsBlank(lclItemVal.Item);
     Collect(InventoryList; 
     {Item: I_Item.Selected.Title; 
     Amount: I_Amount.Text; 
     Photo: Filter_dropdown_photo.SelectedText.Value
     }
     );
     UpdateIf(InventoryList; 
     Item=lclItem.Item; 
     {Amount: lclItem.Amount + Value(I_Amount.Text)}
     )
    )

     

    This will update an existing record if it is there.

    I hope this is helpful for you.

  • alexanderb1 Profile Picture
    19 on at

    Thanks, but it's trowing a lot of errors for this one, starting with LookUp having wrong arguments, also it doesn't seem to recognize the collection. 

     

    PowerApps_Errors.jpg

     

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @alexanderb1 

    That almost looks like this is the ONLY place in your app that you are "Collecting" to the InventoryList collection.

    Are you using ("Collecting" or "ClearCollecting") the InventoryList collection in another place?

     

  • alexanderb1 Profile Picture
    19 on at

    It's just collecting on this single screen, not used on other places. So it's just creating the list on that screen and than I have an option build in to send that list by email.

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @alexanderb1 

    Sorry I seemed to have had a typo in the formula before...the disadvantage of free-typing formulas outside of PowerApps.

    With({lclItem:LookUp(InventoryList; Item=I_Item.Selected.Title)};
    
     If(IsBlank(lclItem.Item);
     Collect(InventoryList; 
     {Item:I_Item.Selected.Title; 
     Amount:I_Amount.Text;
     Photo: Filter_dropdown_photo.SelectedText.Value}
     );
     UpdateIf(InventoryList;
     Item=lclItem.Item; 
     {Amount:Value(lclItem.Amount) + Value(I_Amount.Text)})
     )
    )

    (Also added a little value conversion so the addition works properly)

    I've double checked the above, but I might still be off on a particular semicolon or parenthesis. 

    See if that goes for you.

  • alexanderb1 Profile Picture
    19 on at

    @RandyHayes 

     

    That worked, thank you very much!

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @alexanderb1 

    Excellent!!

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard