cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
AW
Helper II
Helper II

Filter on ClearCollect

I've checked other solutions, but they all are missing some of the complexities of mine. I have a collection "Productlist" of items (Dropdown/Lookup) for an order based on 8 "rows" (Item, Qty, ItemPrice, ItemTotal). I need to filter the Collection to exclude quantities that are blank.

I tried adding the Filter option first, and then tried ForAll, but I can't get it right on either. I think my complication compared to the other solutions I've seen is that they are usually using a list, whereas I'm using multiple fields. So I need to evaluate the exclusion for each quantity field in the collection (Item1Qty, Item2Qty, Item3Qty, etc.) 

My working collection script is below.

 

ClearCollect(
ProductList,
{ColItem: Item1Label.Selected.Title, ColQty: Item1Qty, ColItemPrice: Price1Label, ColItemTotal: Total1Label},
{ColItem: Item2Label.Selected.Title, ColQty: Item2Qty, ColItemPrice: Price2Label, ColItemTotal: Total2Label},,
{ColItem: Item3Label.Selected.Title, ColQty: Item3Qty, ColItemPrice: Price3Label, ColItemTotal: Total3Label},,
{ColItem: Item4Label.Selected.Title, ColQty: Item4Qty, ColItemPrice: Price4Label, ColItemTotal: Total4Label},},
{ColItem: Item5Label.Selected.Title, ColQty: Item5Qty, ColItemPrice: Price5Label, ColItemTotal: Total5Label},},
{ColItem: Item6Label.Selected.Title, ColQty: Item6Qty, ColItemPrice: Price6Label, ColItemTotal: Total6Label},},
{ColItem: Item7Label.Selected.Title, ColQty: Item7Qty, ColItemPrice: Price7Label, ColItemTotal: Total7Label},},
{{ColItem: Item8Label.Selected.Title, ColQty: Item8Qty, ColItemPrice: Price8Label, ColItemTotal: Total8Label},}

);

 

Any help is appreciated

4 REPLIES 4
StalinPonnusamy
Community Champion
Community Champion

Hi @AW 

 

Filter Qty

ClearCollect(
    NewProductList,
    Filter(
        ProductList,
        IsBlank(ColQty) || Value(ColQty) = 0
    )
)

 

Thank you Stalin... I think technically this might produce the correct results (though when I submit 3 items, the gallery shows 5). However, the 2nd collection doesn't bring in values from the items created in the first collection. They are all blank.

StalinPonnusamy
Community Champion
Community Champion

Hi @AW 

 

The 2nd collection will not be updated automatically. You need to call this function again to reset the collection.

AW
Helper II
Helper II

That's where I seem to get stuck. Do I need to add the {ColItem... lines above into your code? I tried it, but it errors out.

Helpful resources

Announcements
User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

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