web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

Delegation

(0) ShareShare
ReportReport
Posted on by 130

I have made an app with excel files as datasources to learn more about creating apps.

It worked as expected, and now I have replaced the excel files with lists in Sharepoint.

Now I get some warnings regarding delegations that I would like to get rid off... 😉

 

Set(Nummer;Max(Table_Indkoebsordre;Indkoebsordrenummer)+1)

 

ClearCollect(AnbefaletIndkoeb;AddColumns(Table_Varer;

"Varetilgang"; Sum(Filter(Table_Lager;Lager_Varenummer=Varenummer;Lager_AntalAbsolut=Lager_AntalReelt);Lager_AntalReelt);
))

 

Can anyone help me to design the right code in the 2 examples above (to get the same result, but without delegation issues)...?

 

Wkr Jørgen

Categories:
I have the same question (0)
  • Scott_Parker Profile Picture
    1,090 on at

    Refer to the delegable functions for SharePoint: SharePoint - Connectors | Microsoft Learn

    Delegation overview

     

    Max() isn't on the list of delegable functions, but Sort() is delegable. Instead of using Max(), use Sort() to get the maximum value as the first record and then get the first value from that.

     

    Sum() isn't delegable to SharePoint and I don't see a workaround for it. The best you can do is have as much delegation as possible before executing the Sum(). You seem to be doing that just fine with the Filter() function inside of the Sum because Filter() is delegable. As long as you don't exceed the data row limit in what is returned from the Filter(), you will be good.

     

    The goal isn't to remove all delegation warnings, but to be aware of which places you aren't/can't use delegable functions and to make sure they will still serve your purposes.

     

  • jlke-as Profile Picture
    130 on at

    Hi Scott

    Thanks for your quick and compentent answer.

    I will use your "First(Sort())" solution - then i will be 100% sure of getting the correct result every time...

     

    Regarding the "Sum(Filter()) I am affraid that I am not as positive...

    My table is regarding stock management keeping track of the quantity of materials going in and out of the warehouse - and the quantity on stock at any time... All transactions of a given material will therefore be included in the filter result, and at a given time there will have been 500 or 2000 records (in and out) - and then the filter will disregard some transactions and the sum will give the wrong result... What would you do to handle this challenge?

     

    wkr Jørgen

  • Scott_Parker Profile Picture
    1,090 on at

    Hi Jlke-as,

    The sum is much tougher in that case because of the large number of rows. Stepping back, I'm willing to bet that ERP systems don't aggregate all of the material transactions any time you want to compute the amount of stock. It would be an increasingly heavy computation load as time progressed with no gain. Instead, as part of the material transaction, the stock quantities for the warehouse are increased/decreased the corresponding amount.

     

    An alterative to updating the stock counter whenever a material transaction occurs is to update the stock counter on a recurring basis. Create a Power Automate flow with a scheduled trigger to update the stock counter say each day. The flow would use the SharePoint connector "Get Items" action to get all material transactions that have occurred from the last time the flow ran to the current time. This could be done with an Sharepoint Get Items action with a filter for transactions in the past day. Those values could then be summed and the stock counter incremented. The Power App would show a combination of the stock counter + the sum of material transactions not yet included in the stock counter as the current stock.

     

    The second way is probably wiser since you don't want to deal with race conditions resulting from multiple attempts to update the same stock counter at the same time.

     

    My apologies, I forgot to hit send on this yesterday.

  • jlke-as Profile Picture
    130 on at

    Hi Scott_Parker

     

    I have created an app based on Sharepoint lists with a limit of 2000 rows regarding delegation...

    One of my lists contains currently approx. 3000 rows of data. and it will keep on increasing ( = delegation is very relevant)...

     

    In my app I have a button in a gallery, that is to update those rows of data which meets a given sets of criterias.

    As you wrote earlier, the filter function is the important part in order to stay with in the limit of 2000 rows....

    I have writen this code, where I have created a filter within a filter, as I assume that the blue part in a filter could cause problems related to delegation... (otherwise I could have all the informations in the same filter)

     

    ---------------

    ForAll(
    Filter(Filter(Table_Tasks;SagNummer=ThisItem.SagNummer;Status=10);";"&ThisItem.TaskNummer&";" in Predecessor);
    Patch(Table_Tasks; ThisRecord;
    {Predecessor: Substitute(ThisRecord.Predecessor; ";"&ThisItem.TaskNummer&";"; "" );
    Status: If(ThisRecord.Predecessor = ";"&ThisItem.TaskNummer&";"; 20; 10);
    Tasks_ChangedBy:CurrentUsername;
    Tasks_ChangedDate:Now()}
    ))

    ---------------

     

    "Table_Tasks" contains approx. 3000 rows of data

    "SagNummer=ThisItem.SagNummer" reduces the rows of data to max 13 rows

    "Status=10" and ";"&ThisItem.TaskNummer&";" in Predecessor reduces the rows of data to those which is to be updated with Status = 20 and ";"&ThisItem.TaskNummer&";" is to be removed from the Predecessor...

     

    It seems to fail from time to time (not always), so I don't know if delegation could be the problem... 

    Could you please help me? 😉

     

    If delegation is not the problem - is there a way to see, what has happend since the code wasn't carried out correctly, when the user pressed the button? (The app control center where errors and performance can be tracked shows nothing as it works fine, when I test the system, but when it fails with another user, I would like to see some kind of log, showing why nothing is being changed when the button is pressed)

     

    Thanks in advance

     

    Wkr Jørgen

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard