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 Platform Community / Forums / Power Apps / how do you remove dupl...
Power Apps
Unanswered

how do you remove duplicate values ​​from your gallery?

(0) ShareShare
ReportReport
Posted on by 84

Hi,

 

I made a page /app with a shoppingart feature, so people can select items from gallery 1 and they collect them in gallery 2.
It works fines with a simple collect code, but now i want something extra... 


Is it possible that if someone select something from gallery 1, its going to check if there is a same item in gallery 2, and if there is a double item, it wont add them at the gallery but add +1 add the amount field in my gallery (it is a text label) like this: 

 

powerapps_problem.png

left is what i got now.. Right is what i want. 

 

I hope there are options to make this. Thanks! 

 

 

 

Categories:
I have the same question (0)
  • Verified answer
    WiZey Profile Picture
    3,023 Moderator on at

    Hello @MelvinGRM ,

     

    You can use "IsBlank()" and "LookUp()" to check if an item exist in a gallery.

     

    I believe the following code should help you:

     

    If(IsBlank(LookUp(cart; ID = ThisItem.ID));
     //IsBlank() = TRUE, no item found
     Collect(...);
     //IsBlank() = FALSE, item found
     UpdateIf(cart; ID = ThisItem.ID; {stock: stock+1})
    )

     

    Hope this was helpful to you.

  • MelvinGRM Profile Picture
    84 on at

    Thanks for your help! 

    I made a mistake, but i dont know where... 

     

    I collect the items in gallery 2 with collect MyCollection: Collect(MyCollection;ThisItem);;

    I assume i have to paste the code at the sellect button of Gallery1 

     

    The stock value is named in my SP database AantalUIT and the textfield in gallery 2 for stock  is calling quant.Text

    so my code 

    If(IsBlank(LookUp(MyCollection; ID = ThisItem.ID));
     //IsBlank() = TRUE, no item found
     Collect(...);
     //IsBlank() = FALSE, item found
     UpdateIf(MyCollection; ID = ThisItem.ID; {AantalUIT: stock+1})
    )

     

    What did i miss? 

    Thanks! 

  • WiZey Profile Picture
    3,023 Moderator on at

    Sorry, I'm not sure I understand your issue here. Could you clarify what is not working or what you're not understanding please?

     

    You're saying your cart is stored in a SharePoint list and not in a local collection? 

  • MelvinGRM Profile Picture
    84 on at

    Excuse me, ignore the last message. 

    The code worked, it adds the item at the gallery, and if it exist, it doesnt add it to the gallery. 

     

    unfortunately it wont add up the stock if i add the same item. It doesnt give an error, code seems fine but i think i miss something.. 

     

    the code: 

    If(IsBlank(LookUp(MyCollection; ID = ThisItem.ID));
    //IsBlank() = TRUE, no item found
    Collect(MyCollection;ThisItem);
    //IsBlank() = FALSE, item found
    UpdateIf(MyCollection; ID = ThisItem.ID; {Aantal: quant+1})
    )

     

    The name of my textfield in the gallery is 'quant' and in the collection the column name is 'Aantal' what is going wrong? Do i need to change my textfield to something else? 

     

    The default of my 'quant field': 

    powerapps_problem.png

     

    Thanks! 

  • WiZey Profile Picture
    3,023 Moderator on at

    I believe you need to:

     

    1. Change the label "Default" property to "Text(ThisItem.Aantal)". Your label must show the value of the record's stock, giving it a constant won't help it change.

     

    2. Change the "UpdateIf()" to this:

     

    UpdateIf(MyCollection; ID = ThisItem.ID; {Aantal: ThisItem.Aantal+1})

     

    I think I remember PowerApps automatically converting any text to a zero-value number when used through any patch. To fix it you want to give it the numerical value of the current stock, which is stored in the "Aantal" property of the item you're updating.

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 711 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 319 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard