cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
milky_bar_may
Helper IV
Helper IV

Filter out from Gallery when Patched

I have a very simple Gallery. 

 

The items in the gallery are coming from Power BI.

 

The code for items in the Gallery is: 

 

 

Sort(
Filter(
PowerBIIntegration.Data,
'Home or Away' = "Home"
),
'Football Manager',
Descending
)

 

My patch function is equally as simple. On Select, filter the gallery that user has selected the checkbox and patch it to create a new record in my SP list.

 

ForAll(
Filter(
Gallery1.AllItems,
Checkbox1.Value = true
),
Patch(
Football,
Defaults(Football),
{
Team: Teamtxt.Text,
Stadium: Stadiumtxt.Text,
Captain: Captaintxt.Text })

 

 

How can I add to my filter code to remove the item from the gallery when it has been patched?

 

For example, a user checks line item 1 and submits it to the list. That item should no longer appear in the Gallery as they have actioned it. How can I filter it out of the Gallery? 

 

Thanks

D

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User III
Super User III

Hi @milky_bar_may ,

I have one solution for you - the problem you have at the moment if that you are filtering the list directly and although you could remove items from the gallery with a check box, this would also remove them from the list. So if you do a Collection at the start and add a field to reflect what you are about to do with the checkbox.

ClearCollect(
   colHome,
   AddColumns(
      Filter(
         PowerBIIntegration.Data,
         'Home or Away' = "Home"
      ),
      "CheckNo",
      false
   )
)

then your Gallery Items

Sort(
   colHome,
   'Football Manager',
   Descending
)

Now the Default of the Checkbox - this then references the field you have added in the collection and is actually to avoid a known bug updating galleries with unbound check boxes resetting when they should not.

ThisItem.CheckNo

The OnCheck of the Checkbox - this updates the new field in the collection to indicate you have selected that record

UpdateIf(
    colHome,
    ID = ThisItem.ID,
    {CheckNo: true}
)

now your Patch

ForAll(
   Filter(
      Gallery1.AllItems,
      Checkbox1.Value = true
   ),
   Patch(
      Football,
      Defaults(Football),
   {
      Team: Teamtxt.Text,
      Stadium: Stadiumtxt.Text,
      Captain: Captaintxt.Text
   }
);
RemoveIf(
   colHome,
   CheckNo = true
)

The last piece added removes all items from the collection with the new field set to true by the checkbox. 

You will need to follow every one of these steps for this to work properly - I have tested this on similar data and it works.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

3 REPLIES 3
WarrenBelz
Super User III
Super User III

Hi @milky_bar_may ,

I have one solution for you - the problem you have at the moment if that you are filtering the list directly and although you could remove items from the gallery with a check box, this would also remove them from the list. So if you do a Collection at the start and add a field to reflect what you are about to do with the checkbox.

ClearCollect(
   colHome,
   AddColumns(
      Filter(
         PowerBIIntegration.Data,
         'Home or Away' = "Home"
      ),
      "CheckNo",
      false
   )
)

then your Gallery Items

Sort(
   colHome,
   'Football Manager',
   Descending
)

Now the Default of the Checkbox - this then references the field you have added in the collection and is actually to avoid a known bug updating galleries with unbound check boxes resetting when they should not.

ThisItem.CheckNo

The OnCheck of the Checkbox - this updates the new field in the collection to indicate you have selected that record

UpdateIf(
    colHome,
    ID = ThisItem.ID,
    {CheckNo: true}
)

now your Patch

ForAll(
   Filter(
      Gallery1.AllItems,
      Checkbox1.Value = true
   ),
   Patch(
      Football,
      Defaults(Football),
   {
      Team: Teamtxt.Text,
      Stadium: Stadiumtxt.Text,
      Captain: Captaintxt.Text
   }
);
RemoveIf(
   colHome,
   CheckNo = true
)

The last piece added removes all items from the collection with the new field set to true by the checkbox. 

You will need to follow every one of these steps for this to work properly - I have tested this on similar data and it works.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

View solution in original post

Hi @milky_bar_may ,

Just checking if you got the result you were looking for on this thread. Happy to help further if not.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Hi @WarrenBelz 

 

Thank you so much. 

 

It worked a treat - you are a star.

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Are Your Ready?

Test your skills now with the Cloud Skill Challenge.

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (59,103)