cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
iemdan
Regular Visitor

Double filtering a gallery

I have a gallery of items that I'd like it to be filtered so the results are the items that match the selected brand(s) as well as equals or greater than selected battery capacity amount. This is the code on my gallery:

 

Filter(
AccessoriesList,
If(
IsBlank(BrandSelection.Selected),
true,
deviceBrand in BrandSelection.SelectedItems
),
If(
IsBlank(BatterySelection.Selected),
true,
deviceBatteryUse >= Max(BatterySelection.SelectedItems, Battery)
)
)

 

"AccessoriesList" is a SharePoint data list that contains an accessory, it associated brand and its associated battery capacity. "BrandSleection" and "BatterySelection" are both combo boxes that are connected to the same another SharePoint DB with the list of devices with their brands and battery cap.

 

The error I got indicated that Max can only be done with a table, where BatterySelection is a list. So do I somehow need to convert the list to a table for it to work? Or is my solution a no-good to begin with?

1 ACCEPTED SOLUTION

Accepted Solutions

Try, for testing, a hard number without quotes like 5000 in place of Battery. If that does not give an error, it's probably that Battery is not being interpreted as a number.

 

You can try Value(Battery)

View solution in original post

7 REPLIES 7
RezaDorrani
Dual Super User II
Dual Super User II

Hi @iemdan 

 

plz post a screenshot of BatterySelection combo box Items property and Value property

sopatte
Microsoft
Microsoft

First, "If(X,true,Y)" is equivalent to "X || Y".

 

So you could replace that with 

Filter(AccessoriesList
    ,IsBlank(BrandSelection.Selected) 
    || deviceBrand in BrandSelection.SelectedItems
    ,IsBlank(BatterySelection.Selected)
    || deviceBatteryUse >= Max(BatterySelction.SelectedItems, Battery)
)


As far as your Max() function, this should work if Battery and deviceBatteryUse are numeric fields.

v-yutliu-msft
Community Support
Community Support

Hi @iemdan ,

 

Try this formula:

Filter(
        AccessoriesList,
        If(
           IsEmpty(BrandSelection.SelectedItems),   //combo box do not have selected property, IsBlank is used to justy empty value, not empty table
           true,
           deviceBrand in BrandSelection.SelectedItems.fieldname    //BrandSelection.SelectedItems result a table, not some value
           ),
          If(
            IsEmpty(BatterySelection.SelectedItems),
            true,
            deviceBatteryUse >= Max(BatterySelection.SelectedItems, Battery)
             )
       )

 

Best regards,

Community Support Team _ Phoebe Liu

Community Support Team _ Phoebe Liu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
iemdan
Regular Visitor

Hi there,

 

Thanks for your  solution .there seems to be an error . Am i missing something?

Hi there,

 

I'm attaching some screenshots. These arey:

 

- "Test List" table with devices and each's own battery capacity

- "AccessoriesList" table with a list of the battery banks and associated device battery capacity

- Battery combo list dropdown with the formula

Hi there,

 

Thanks for the code. What  should I put to replace "fieldname" ?

Try, for testing, a hard number without quotes like 5000 in place of Battery. If that does not give an error, it's probably that Battery is not being interpreted as a number.

 

You can try Value(Battery)

View solution in original post

Helpful resources

Announcements
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

Welcome Super Users.jpg

Super User Season 2

Congratulations, the new Super User Season 2 for 2021 has started!

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Top Solution Authors
Top Kudoed Authors
Users online (2,735)