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

Community site session details

Session Id :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Total Record Count using REST API $select

(0) ShareShare
ReportReport
Posted on by 5

Hi,

I am trying to implement Search using $search. I want to get the total record count upon each query. But in case if there are more than 5000 records, no matter what I do, I never get the total records requested. If I apply a filter that returns less than 5000 then I get the correct figure. But if the records are less then I get -1 because I cannot use $top with $count.

I cannot use the RetrieveTotalRecordCount function because that will return the count of ALL records of an entity.

Is there a way I can get a correct count of the records that are returned by the query.

Regards.

Adeel.

I have the same question (0)
  • Martin Dráb Profile Picture
    236,552 Most Valuable Professional on at
    RE: Total Record Count using REST API $select

    Which of the Dynamics 365 products is this question about?

  • Suggested answer
    Guido Preite Profile Picture
    54,084 Moderator on at
    RE: Total Record Count using REST API $select

    use my tool Dataverse REST Builder to generate the query (Retrieve Multiple request type) and make sure you select Retrieve Count as Yes

    after you can see how the query string and the headers are generated

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Total Record Count using REST API $select

    Hi Partner,

    Yes. it is limited to 5,000 rows.

    Maybe you can try to use other ways to get correct count when you query records with filter: 

    1.create one report for the entity.

    Create a report using the report wizard, specify the criteria:

    pastedimage1655286462855v1.png

    In the LayOut fields window, specify Count as the summary type for grouping.

    pastedimage1655286462856v2.png

    Run the report to get the count.

    pastedimage1655286462856v3.png

    2.use the FetchXMLBuilder plugin of the XrmToolBox to build the query , copy it.

    pastedimage1655286624246v4.png

    Then use it in the FetchXML / View Record Counter.

    Select the entity, contact, in this case, paste the FetchXML query and click Execute Count.

    pastedimage1655286624247v5.pngpastedimage1655286624247v6.png

    We will get the count.

    pastedimage1655286624248v7.png

    You can refer the following link for more details:

    How to – Different ways of getting record count (total) in Dynamics 365 – Nishant Rana's Weblog

  • Dynamics 365 REST API Profile Picture
    5 on at
    RE: Total Record Count using REST API $select

    I am using REST API to query Dataverse

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 169

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 77 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 71

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans