cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
lph
Frequent Visitor

Filter gallery based on user input to combobox

I have two sharepoint lists:

(1) lst_products

product_namepurchasing_manager
applebob
banannatom
broccolialice
garbage bagsjane

 

(2) lst_product_vendors

vendor_nameproduct_nameprice_per_unit_usd
vendor abananna0.35

vendor a

broccoli0.65

vendor a

garbage bags2.10
vendor bapple0.51
vendor capple0.45
vendor cgarbage bags2.65
vendor cbanana0.37

 

I am trying to create a gallery that will display the purchasing_manager for products supplied by a particular vendor. So for example:

  • User specifies 'vendor a' in ComboBox --> sees vertical gallery for purchase_managers Tom and Alice
  • User specifies 'vendor b' and 'vendor c' --> sees vertical gallery for purchase_managers Bob, Tom, Jane

 

To do so I have:

  • ComboBox with name 'cmbSelectVendors' where Items = Choices( lst_product_vendors.vendor_name )

And tried a number of different things to get the vertical gallery to display the purchasing_manager from lst_products:

  • Items = Filter( lst_products, product_name in cmbSelectVendors.SelectedItems)
  • Items = Filter (lst_products, product_name in cmbSelectVendors.SelectedItems.Value )
  • Items = Filter (lst_products, product_name in Concat(cmbSelectVendors.SelectedItems, Value) )

But no luck. What am I doing wrong here?

 

 

1 ACCEPTED SOLUTION

Accepted Solutions
RandyHayes
Super User
Super User

@lph 

Well...starting from the end of your response and working up.

You will not get Choices to work.  What you are looking for is Distinct - Distinct(lst_product_vendors, vendor_name)

Choices is for complex columns (Choices, Lookup, Person, etc)

 

This will give you a distinct list, but the formula I demonstrated actually takes this a step further.  GroupBy essentially does a distinct as well, but it also returns the matching records to the distinct value.  What I was going for was...do your formula in ONE place rather than two places.

This way, for your other list of purchasing managers, the information is already there...in the dropdown.  We don't need to do more data actions to get it.

 

NOW...here is where the problem is.  You have renamed your Title column in your lists.  You can never really rename a column in SharePoint.  It will always retain its original name.  When you rename it, SharePoint will "remember" what you named it and will display it everywhere with the name you gave, but, under the covers...it is still the original name (Title in this case).

 

PowerApps honors the name change in most places, but in areas where you quote a name, it must be the original.

SO...

Here is what your formula needs to be:

 AddColumns(
        GroupBy(
            AddColumns(
                lst_product_vendors As _vendor,
                "prodMgr", LookUp(lst_products, product_name=_vendor.product_name, purchasing_manager)
            ),
            "Title", "_recs"
        ),
        "Managers", Filter(_recs, !IsBlank(prodMgr))
    )

 

lph.gif

 

_____________________________________________________________________________________
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

5 REPLIES 5
RandyHayes
Super User
Super User

@lph 

I think in your example, if vendor A is selected, then Tom, Alice and Jane would be displayed...

 

For your Vendor cmbSelectVendors, set the Items property to:

 AddColumns(
        GroupBy(
            AddColumns(
                lst_product_vendors As _vendor,
                "prodMgr", LookUp(lst_products, product_name=_vendor.product_name, purchasing_manager)
            ),
            "vendor_name", "_recs"
        ),
        "Managers", Filter(_recs, !IsBlank(prodMgr))
    )

 

For the Managers Combobox, set the Items property to:

    cmbSelectVendors.Selected.Managers

 

I hope this is helpful for you.

 

_____________________________________________________________________________________
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!
lph
Frequent Visitor

Thank you, @RandyHayes for the reply. I assume I am just dense since I can't get most things in powerapps to work but struggling to implement your suggestion. Here is what I am doing:

 

Two lists, lst_product_vendors and lst_products:

 

Screenshot 2021-03-03 235241.png

 

lst_product_vendors on Sharepoint:

Screenshot 2021-03-03 235437.png

lst_products

 

Screenshot 2021-03-03 235527.png

 

Back over to cmbSelectVendors, no dice:

Screenshot 2021-03-04 000049.png

 

Not even sure where to start with that formula but why wouldn't something as simple as the following work to just get a list of unique vendor_names in the combo box? 

Screenshot 2021-03-04 000717.png

 

By setting Items = lst_product_vendors I can get it to do the following:

Screenshot 2021-03-04 001034.png

But if I only want to have to click on 'vendor a' once to view info in a gallery for the purchasing_managers responsible for product_names sold by 'vendor a'? 

 

RandyHayes
Super User
Super User

@lph 

Well...starting from the end of your response and working up.

You will not get Choices to work.  What you are looking for is Distinct - Distinct(lst_product_vendors, vendor_name)

Choices is for complex columns (Choices, Lookup, Person, etc)

 

This will give you a distinct list, but the formula I demonstrated actually takes this a step further.  GroupBy essentially does a distinct as well, but it also returns the matching records to the distinct value.  What I was going for was...do your formula in ONE place rather than two places.

This way, for your other list of purchasing managers, the information is already there...in the dropdown.  We don't need to do more data actions to get it.

 

NOW...here is where the problem is.  You have renamed your Title column in your lists.  You can never really rename a column in SharePoint.  It will always retain its original name.  When you rename it, SharePoint will "remember" what you named it and will display it everywhere with the name you gave, but, under the covers...it is still the original name (Title in this case).

 

PowerApps honors the name change in most places, but in areas where you quote a name, it must be the original.

SO...

Here is what your formula needs to be:

 AddColumns(
        GroupBy(
            AddColumns(
                lst_product_vendors As _vendor,
                "prodMgr", LookUp(lst_products, product_name=_vendor.product_name, purchasing_manager)
            ),
            "Title", "_recs"
        ),
        "Managers", Filter(_recs, !IsBlank(prodMgr))
    )

 

lph.gif

 

_____________________________________________________________________________________
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

lph
Frequent Visitor

Aha, you are the man! Thank you so much for the explanation -- would really be great if microsoft had some kind of instruction manual or documentation all in one place that addressed these kinds of things instead of links to 368,000 different articles, etc. but thank you again!

RandyHayes
Super User
Super User

@lph 

They kind of do, but it is obscure and usually laden with collections...which you rarely need.

The column rename thing trips up a lot of people too.

Glad you have it going now though!! 

_____________________________________________________________________________________
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 (2,129)