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

Multiple Filters on a Gallery causes Delegation Issues

Hello everyone,

 

I've been making an app to keep track of security tests my boss performs for our clients.

On this particular page I've made a gallery glrTestsPerControl that shows the tests related to the control assessments in glrListofControlGAPS.

RutgervdH95_0-1637937935701.png

 

A toggleswitch has been added that changes the variable varSortTestsPerControl between 'Test Id' and 'Test Completion Date' to sort the gallery on either of those values.

Next we're trying to add a filter independently controlled by a checkbox that toggles a boolean varDistinctTestsPerControl to only show the most recently completed test of each Test Id.
The code is as follows:


If(varDistinctTestsPerControl=true; ForAll(Distinct(glrListofControlGAPS.Selected.'RisqTrack Tests';'Test Id');
First(Filter(SortByColumns(glrListofControlGAPS.Selected.'RisqTrack Tests';"rrb_testid";
If(varSortTestsPerControl="rrb_testcompletiondate";Descending;Ascending));'Test Id'=Result)));
SortByColumns(glrListofControlGAPS.Selected.'RisqTrack Tests';varSortTestsPerControl;
If(varSortTestsPerControl="rrb_testcompletiondate";Descending;Ascending)))

 

This works the first time, but after refreshing or exporting the app, several columns come back empty, which I'm told is a delegation issue?

RutgervdH95_1-1637937976585.png

To make a long story short:
Any advice on how to add these filters and sorting functions without overtaxing PowerApps?

 

Thanks,

Rutger

1 ACCEPTED SOLUTION

Accepted Solutions
WarrenBelz
Super User
Super User

Hi @RutgervdH95 ,

I do not know exactly what you re doing here (so have relied on your values/structure, but if your record numbers are under your Delegation limit, this should get rid of the warning (Distinct is not Delegable)

With(
   {
      wList:glrListofControlGAPS.Selected.'RisqTrack Tests';
      wSortD:varSortTestsPerControl="rrb_testcompletiondate"
   }
   If(
      varDistinctTestsPerControl; 
      ForAll(
         Distinct(
            wList;
            'Test Id'
         );
         LookUp(
            SortByColumns(
               wList;
               "rrb_testid";
               If(
                  wSortD;
                  Descending;
                  Ascending
               )
            );
            'Test Id'=Result
         )
      )
   );
   SortByColumns(
      wList;
      "rrb_testid";
      If(
         wSortD;
         Descending;
         Ascending
      )
   )
)

 

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.

Visit my blog Practical Power Apps

View solution in original post

1 REPLY 1
WarrenBelz
Super User
Super User

Hi @RutgervdH95 ,

I do not know exactly what you re doing here (so have relied on your values/structure, but if your record numbers are under your Delegation limit, this should get rid of the warning (Distinct is not Delegable)

With(
   {
      wList:glrListofControlGAPS.Selected.'RisqTrack Tests';
      wSortD:varSortTestsPerControl="rrb_testcompletiondate"
   }
   If(
      varDistinctTestsPerControl; 
      ForAll(
         Distinct(
            wList;
            'Test Id'
         );
         LookUp(
            SortByColumns(
               wList;
               "rrb_testid";
               If(
                  wSortD;
                  Descending;
                  Ascending
               )
            );
            'Test Id'=Result
         )
      )
   );
   SortByColumns(
      wList;
      "rrb_testid";
      If(
         wSortD;
         Descending;
         Ascending
      )
   )
)

 

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.

Visit my blog Practical Power Apps

View solution in original post

Helpful resources

Announcements
2022 Release Wave 1 760x460.png

2022 Release Wave 1 Plan

Power Platform release plan for the 2022 release wave 1 describes all new features releasing from April 2022 through September 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,437)