cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
KarlAddi
Helper I
Helper I

Remove Function not removing

What I want to happen is that when the quantity goes to zero, the remove function removes the item from the gallery. 

 

I might be going crazy but when I first added the IF function it worked but now it wont remove the item until the quantity is < 0 not <= 0. 

 

 

Patch(Table1,LookUp(Table1,Name = PartName.Text),{Qty:Value(CurrentStock.Text - OrderQuantityText.Text)});

If(Value(CurrentStock.Text) <= 0, Remove([@Table1], BrowseGallery1.Selected),"");

Notify("Item Removed Successfully",NotificationType.Success);

Reset(OrderQuantityText);

Navigate(BrowseScreen,ScreenTransition.Fade);

 

 

14 REPLIES 14
RandyHayes
Super User
Super User

@StalinPonnusamy 

If that is the case, then @KarlAddi you can incorporate that into the formula as well:

With({_item: BrowseGallery1.Selected},

    UpdateIf(Table1,
        Name = PartName.Text,
        {Qty: Value(CurrentStock.Text) - Value(OrderQuantityText.Text)
    );

    If(Value(CurrentStock.Text) - Value(OrderQuantityText.Text) <= 0, Remove([@Table1], _item);
       
    Notify("Item Removed Successfully",NotificationType.Success);
    Reset(OrderQuantityText);
    Navigate(BrowseScreen,ScreenTransition.Fade)
)

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

Yes, So the user is updating the quantity of that record but if the quantity is 0 I'd want that same record to be deleted

RandyHayes
Super User
Super User

@KarlAddi 

@StalinPonnusamy  point was that if the original value in CurrentStock was 10 and the user set the order quantity to 10, then the result is 0, but your formula is not accounting for removing that record if that mathematical formula is evaluated.  You are only looking at the CurrentStock value, which would still be 10.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

That solved it ! Thank you very much @RandyHayes & @StalinPonnusamy . So the IF statement checked to see if the result of changing the quantity is <= 0 and then it executes ? 

RandyHayes
Super User
Super User

@KarlAddi 

Sometimes it's the simple things!  I had envisioned that this was some other way, but not the case.

Glad you've got it now.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,723)