cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Anonymous
Not applicable

CountIf() Displaying Wrong Number

Hi,

 

I have a Gallery with a sql view as a data source, with a Label that has the Text property:

 

CountIf('[dbo].[vw_FldAppr_GWShip_30Day]', ModelNumber = Label5.Text

 

The only purpose this serves is to give the user a preview of the # of units in the view that contain that model #.  However, the CountIf() function often displays the wrong number, even after a refresh.

 

Could the problem be the fact that I'm pulling from a SQL view? Whenever I add a view as a data source there's typically a 1-2 hr delay before I can actually use it in my app. Does this delay apply to the values inside it as well? 

 

Thanks in advance!

1 ACCEPTED SOLUTION

Accepted Solutions
v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Firstly, there is no official doc mentioned about the rows retrieved from a SQL View into an app in PowerApps currently.

 

The CountIf function is a non-delegable function in PowerApps, so it could not delegate the data process from your app to your SQL Table data source.

In other words, the CountIf function could only process data locally in your app. In default, it could only process 500 records at most locally in your app. You could change the "Data row limits for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App setting of your app, then you could process 2000 reocrds at most locally.

 

Please consider change the "Data row limits for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App setting of your app, then try your formula again, check if the issue is solved.

 

In addition, as an alternative solutionm, please take a try with the following workaround (Set the Text property of the Label to following😞

Sum(
     ForAll(
            Filter('[dbo].[vw_FldAppr_GWShip_30Day]', ModelNumber = Label5.Text),
            1
     ),
     Value
)

Please take a try with above solurion, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
RezaDorrani
Dual Super User II
Dual Super User II

Hi @Anonymous 

 

2 reasons, one is the delay

 

more important is delegation

I believe is not a delegable function and hence condition will only check in first 2k rows (depending upon your delegation limit set)

https://docs.microsoft.com/en-us/connectors/sql/

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

Anonymous
Not applicable

Thanks @RezaDorrani ,

 

I have no delegation warning & less than 2k rows in my view so unfortunately it just seems to be the way views interact with PowerApps.  

v-xida-msft
Community Support
Community Support

Hi @Anonymous ,

Firstly, there is no official doc mentioned about the rows retrieved from a SQL View into an app in PowerApps currently.

 

The CountIf function is a non-delegable function in PowerApps, so it could not delegate the data process from your app to your SQL Table data source.

In other words, the CountIf function could only process data locally in your app. In default, it could only process 500 records at most locally in your app. You could change the "Data row limits for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App setting of your app, then you could process 2000 reocrds at most locally.

 

Please consider change the "Data row limits for Non-delegable queries" option to maximum value -- 2000 within Advanced settings of App setting of your app, then try your formula again, check if the issue is solved.

 

In addition, as an alternative solutionm, please take a try with the following workaround (Set the Text property of the Label to following😞

Sum(
     ForAll(
            Filter('[dbo].[vw_FldAppr_GWShip_30Day]', ModelNumber = Label5.Text),
            1
     ),
     Value
)

Please take a try with above solurion, check if the issue is solved.

 

Best regards,

Community Support Team _ Kris Dai
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

Anonymous
Not applicable

Delegation was not the issue, but your workaround worked like a charm! Thank you!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (1,113)