cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Frankie70
Post Patron
Post Patron

Allow only one item of a catergory in the collection

Hi all,

 

i have a shop with 4 categories (cat1, cat2, cat3, cat4)

I want the users only allow to order 1 item of cat1 but as many as they want from cat2, cat3, cat4

I have this on my shopping tray icon:

DisplayMode: If(LookUp(basket,itemcat=Gallery4.Selected.Category,itemcat)="cat1"),Disabled,DisplayMode.Edit)

 

BUT, when I switch to another category in my shop, put an item in my collection("basket") and switch back to cat1, I am able to buy another item of cat1.

 

How can I fix that?

1 ACCEPTED SOLUTION

Accepted Solutions

Yeah, that makes sense - and yes we absolutely can change it

 

 

If(
   Gallery4.Selected.Category="cat1"
   &&
   CountRows(Filter(basket,itemcat="cat1")) > 0,
   Disabled,DisplayMode.Edit
)

 

 

So if there is already on in the basket (countrows) and the current selected one is cat1, then disable, otherwise enable it

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


View solution in original post

4 REPLIES 4
iAm_ManCat
Super User
Super User

Hi!

 

When you change the category, your selected item in that gallery is going to change, which then makes your formula allow it as its looking at that selected item from the gallery.

 

You could try counting the number of rows in your basket containing cat1 and if that is > 0 then disable it:

 

DisplayMode:

If(
   CountRows(Filter(basket,itemcat="cat1")) > 0,Disabled,DisplayMode.Edit
)

 

Could you try this and let me know if you encounter any issues?

 

Thanks,

Sancho

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Hi @iAm_ManCat 

thanks for your answer.

Unfortunately I can not put anything of the other categories in the basket, because there is already one item of cat1 in the collection, and so it is disabled 😞

Any other idea?

Yeah, that makes sense - and yes we absolutely can change it

 

 

If(
   Gallery4.Selected.Category="cat1"
   &&
   CountRows(Filter(basket,itemcat="cat1")) > 0,
   Disabled,DisplayMode.Edit
)

 

 

So if there is already on in the basket (countrows) and the current selected one is cat1, then disable, otherwise enable it

@iAm_ManCat


Please 'Mark as Solution' if someone's post answered your question and always 'Thumbs Up' the posts you like or that helped you!


Thanks!
You and everyone else in the community make it the awesome and welcoming place it is, keep your questions coming and make sure to 'like' anything that makes you 'Appy
Sancho Harker, MVP


Thanks a lot, that did the trick!

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

PWREduCon768x460.png

Join us at PWR EduCon - A Power Platform Conference

Learn from the top Power BI, Power Apps, Power Automate & Power Virtual Agents experts!

Top Solution Authors
Top Kudoed Authors
Users online (3,237)