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 / Change Display mode if...
Power Apps
Answered

Change Display mode if category exits alread in collection

(0) ShareShare
ReportReport
Posted on by 384

Hi all! 

I have several items in my collection, each has a category.

My goal is to disable the "Buy" button (DisplayMode) in my gallery if an item of a specific category is already in my collection.

Can someone advise how to do that?

 

Categories:
I have the same question (0)
  • VDS_Mantra Profile Picture
    175 on at

    Hi, 

     

    this is the small data i took in my collection 

    Collect(IceCream, { Flavor: "Chocolate", Quantity: 1100 }, { Flavor: "Vanilla", Quantity: 200 } )

     

    and basis on that search i have set my buy button display mode. 

    If(LookUp(IceCream, Flavor = "Chocolate", Quantity )=100,Disabled,Edit)

     

    Hope it will help to resolve your problem. 

     

  • Frankie70 Profile Picture
    384 on at

    @VDS_Mantra 

    Thanks for your reply.

    I am not sure, what goes wrong.

    If (LookUp(basket, itemcat = 'Laptop',DisplayMode.Disabled, DisplayMode.Edit))

    Maybe you can give me a hint?

  • VDS_Mantra Profile Picture
    175 on at

    Hi, 

     

    Use below one it will resolve your problem. 

    "If (LookUp(basket, itemcat = 'Laptop',itemcat) = "Laptop",Disabled, DisplayMode.Edit)"

     

    Here Basket is the name of Collection Variable, and Itemcat is one of the header, So you need to lookup the items basis on some field. so here we are searching Itemcat based on Itemcat = Laptop. As i have lookup Icecream Quantity based on Flavor in my example. 

     

    Hope you got my point. see the below lookup function Syntax.  

    LookUpTableFormula [, ReductionFormula ] )

     

     

     

     

     

  • Frankie70 Profile Picture
    384 on at

    @VDS_Mantra 

    Hi,

    thanks, the formula throws no error anymore, but the DisplayMode is not set to disabled in my case although in my collection (basket) there is an item with the category "Laptop".

    Frankie70_0-1594124792699.png

    Something is still wrong...any idea?

  • VDS_Mantra Profile Picture
    175 on at

    Hi, 

     

    Can you please share your collection variable snapshot.

  • Frankie70 Profile Picture
    384 on at

    @VDS_Mantra 

    Hi,

    here it is:

    Collect(basket, {itemname: Gallery4.Selected.Title, itemcat: Gallery4.Selected.Category})

    Frankie70_0-1594126889513.png

     

  • VDS_Mantra Profile Picture
    175 on at

    Hi,

     

    Use this one..

     

    "If (LookUp(basket, itemcat = "Laptop",itemcat) = "Laptop",Disabled, DisplayMode.Edit)"

     

    I am sure it will surely work for you. 

     

  • Frankie70 Profile Picture
    384 on at

    @VDS_Mantra 

    Ok grat, that worked. It was only the double quotas...

    But I forgot something: Now the button for the items with Category= "Peripherie" or "Mobile" are also disabled...

    How can I include theses cases into the formula?

    Frankie70_0-1594128255956.png

     

  • VDS_Mantra Profile Picture
    175 on at

    Hi,

     

    the best way of doing this that you set a variable value of your selected items and then use like below function. 

     

    If(LookUp(basket,itemcat=VItemcat,itemcat) = VItemcat, Disabled,DisplayMode.Edit)

     

    i have set this variable from dropdown selection so it will work for each items whichever you will select from dropdown. 

    Set(VItemcat,Dropdown1.Selected.Value) 

     

    or you may use this

     

    If(LookUp(basket,itemcat="Mobile",itemcat) = "Mobile" ||LookUp(basket,itemcat="Laptop",itemcat) = "Laptop",Disabled,DisplayMode.Edit)

     

    As per me first option is best. 

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more.

     

  • Frankie70 Profile Picture
    384 on at

    @VDS_Mantra 

    Thanks for you replies!!

    If (LookUp(basket, itemcat = "Mobile",itemcat) = "Mobile" || LookUp(basket,itemcat="Laptop",itemcat) = "Laptop",Disabled,DisplayMode.Edit) does not work.

    When I choose a Laptop, then the shopping options for more laptops are disabled, which is correct.

    But when I go to Mobile section, these are already disabled as well. My aim is that users can only choose 1 laptop and 1 mobile device, nbut multiple devices as peripherie.

    Frankie70_0-1594132915394.png

     

    Frankie70_1-1594132956609.png

     

    Frankie70_2-1594133017103.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

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

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 343 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard