This suggested solution works both on Sharepoint and SQL Server. Create an integer field or column in your source table, make 1 as a default for it. In all my tables, I call that extra field "ic" as integer count, or whatever you may call it. So every time a new record is added, 1 is automatically given to its "ic". You see a number is delegable to the backend in both Sharepoint and SQL Server. So if you make "ic" as a parameter in your Sum() function, you get the sum of all your records no matter if they exceed 2000 rows.
Here's an example on how I'm using that extra field for counting the number of records. In all my apps, it's been my practice to give a user an info about how many records there are in the datasource when he filters the gallery by entering some characters in a textbox. It's an extract of a record counting block of code in my equipment maintenance app.
Sum(
Search(
Filter( 'mySQLServerDatasource', (ic = 1) ),
Trim(txtSearch.Text),
"EQUIPID",
"EQUIP_DESCR",
"STAGE_ID",
"FACILITY",
"TYPENAME",
"MAINT_TEMP",
"PROVIDER",
"SPECIALIZED",
"BYPASS_REASON"
),
ic
)
I put this block of code behind the text property of a label that shows the record count.
1.) First, the Filter() function filters against the datasource with "ic=1".
2.) Then Search() searches for records which fields that may contain the string of characters in the trimmed txtSearch.Text . The user types some characters into this textbox to search.
3.) Finally, the Sum() function sums up the resultset's ic. This is now the count of records.
Instead of using CountRows() to count the number of records, I use Sum() against the "ic" to give me the count of records. I watched someone's video that does similar way to count the records with more than 2000 records but he used Flow to do it. He passed some parameters for Flow to do his CountRows. My method doesn't need Flow to get the count; it's using Sum() with that extra integer field with 1 as the default.