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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / How to overcome delega...
Power Apps
Answered

How to overcome delegation issue that we face with Countrows and Countif

(2) ShareShare
ReportReport
Posted on by 13
Hello Everyone,
 
I have a SharePoint list that has over 5000 records and i want to show the total count in a text label on a screen and i dont want to use Power Automate flow (send an Http request action).
As we know Countrows is non-delegable on SharePoint and I was looking for a turnaround by using
 
UpdateContext({records: Filter(<Order5000>, Category.Value = "Electronics")});
UpdateContext({recordcount: records.allitems})
 
in the text label control I only see 500 records. Is there a way without using Power automate to get the Electronic count which is 848 total out of 5000 in a Text label. Is there any other function that i can use.
 
 
Categories:
I have the same question (0)
  • Suggested answer
    CU25020938-0 Profile Picture
    71 on at
    Hi,
    I learnt this from my gigachad colleague, this is what you can do:
    Utilize graph API to create a collection of all the items and then you can filter and countrows that collection based on your conditions.
     
    Step 0:
    Add an Office365Groups connector to your app
     
    Step 1:
    Create a component in PowerApps, I called it Looper
    Add a New Custom Property called URL (or anything), set data type to Text and check "Raise OnReset when value changes" and also make sure Access app scope is On.
     
     
    Step 2:
    Set the OnReset Property to this:
     
    If(
        IsMatch(
            Self.URL,
            "https://",
            MatchOptions.BeginsWith
        ),
        With(
            {
                MyAPIcall: Office365Groups.HttpRequest(
                    Self.URL,
                    "GET",
                    ""
                )
            },
            Collect(
                CollectionThatYouWillStoreTheData, //Name it as you wish
                ForAll(
                    Table(MyAPIcall.value),
                    {
                        ID: Value(Value.id),
                        Title: Text(Value.fields.Title),
                        Name: Text(Value.fields.NAME), //repeat for all columns you want to fetch
                        Numbers: Value(Value.fields.ANUMBERCOLUMN) //repeat for all columns you want to fetch
                    }
                )
            );
            Set(
                GraphAPIURL,
                Text(MyAPIcall.'@odata.nextLink')
            )
        )
       
    )

    Step 3:
    Add this Component to the screen where you would do the operation (Insert > Custom > Looper component). You can make it invisible or 0x0 px.
     
    Step 4 (optional button): I created a button to start the API call, but if you want to connect it to an event or an OnStart or anything you can use that
    Set the Button OnClick to this:
     
     
    Clear(CollectionThatYouWillStoreTheData); /just in case you press it twice accidentally you don't want duplicate records.
     
    Set(GraphAPIURL, "https://graph.microsoft.com/v1.0/sites/[Your Site ID]/lists/[Your List ID]/items?$expand=fields($select=Title,NAME,ANUMBERCOLUMN)&$top=5000")
    Replace NAME, ANUMBERCOLUMN with any columns you also want to store in the collection and make sure you include them in the OnReset as well. ID is default here, you don't need to add it.
     
     
    What it does, is it fetches the first 5000 rows from your sharepoint list, and if there is a 'nextLink' parameter in the response, it will trigger a Reset in the component which then runs the query again for the next 5000 rows.
     
    Now you have a collection with all the rows and you can do the filtering and count rows.

    Hope this helps.
     
  • CU25020938-0 Profile Picture
    71 on at
    Sorry i forgot to mention that you need to set the URL property of the component that you added to your screen in step 3 to GraphAPIURL
  • Suggested answer
    Michael E. Gernaey Profile Picture
    53,969 Moderator on at
    Hi
     
    1) the default delegation size is 500, you need to change the property under settings to make it between 500 and 2000
    2) What you need to do is use a With
     
    With(
               {MyRecords: Filter(sourcea, x =x) },
     
              CountRows(MyRecords)
    )
  • CU25020938-0 Profile Picture
    71 on at
    @FLMike Said:
    Hi
     
    1) the default delegation size is 500, you need to change the property under settings to make it between 500 and 2000
    2) What you need to do is use a With
     
    With(
               {MyRecords: Filter(sourcea, x =x) },
     
              CountRows(MyRecords)
    )
     
    This is not entirely correct, because if the number of rows after filtering exceed the data row limit you set in settings (2000), countrows will only count up to the data row limit (2000)
     
    I created a mockup to test this, my list has around 6000 rows, and i specifically changed the Picker value to Choice 2 on 2100 lines, then i ran this and only got 2000



     

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 505

#2
WarrenBelz Profile Picture

WarrenBelz 502 Most Valuable Professional

#3
Haque Profile Picture

Haque 324

Last 30 days Overall leaderboard