cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
samdolphin
Level: Powered On

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
Community Support Team
Community Support Team

Re: CountIf() Displaying Wrong Number

Hi @samdolphin ,

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
Dual Super User
Dual Super User

Re: CountIf() Displaying Wrong Number

Hi @samdolphin 

 

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

 

samdolphin
Level: Powered On

Re: CountIf() Displaying Wrong Number

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.  

Community Support Team
Community Support Team

Re: CountIf() Displaying Wrong Number

Hi @samdolphin ,

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

samdolphin
Level: Powered On

Re: CountIf() Displaying Wrong Number

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

Helpful resources

Announcements
thirdimage

Power Apps Super User Class of 2020

Check it out!

thirdimage

New Badges

Check it out!

thirdimage

Power Apps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

SecondImage

Difinity Conference

The largest Power BI, Power Platform, and Data conference in New Zealand

Top Solution Authors
Top Kudoed Authors
Users online (5,283)