We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

can''t get countif function to work in v 3.3 final

Thread ID:





36504 Nov 1,2005 05:56 PM UTC Nov 2,2005 09:49 AM UTC WinForms 3
Tags: Calculate
Byron Tate
Asked On November 1, 2005 05:56 PM UTC

I have 2 issues - result value, and syntax. countif description says: --------------------------------------- Counts the number of cells within a range that meet the given criteria. Syntax COUNTIF(range,criteria) range is the range of cells from which you want to count cells. criteria is the criteria in the form of a number, expression, or text that defines which cells will be counted. For example, criteria can be expressed as ">32". ------------------------------------------------ This seems to say that if A1 = 0 and A2 = 1, then =countif(A1:A2,NOT(A0 = 0)) should result in a value of 1 (assume ''using zero row notation'' is on). But my testing shows that it results in a value of 0 on line 1 and 2 on line 2. It''s as if the logic is actually ''return the count of A1:A2 if the current line''s A column is not = 0, otherwise return 0''. Second issue: I can''t just write: =countif(A1:A2,">0") because it complains about the second arg. Also I can''t write: =countif(A1:A2,A0 = 1) because it complains that there are not enough args on the stack, which means it did not recognize ''A0 = 1'' as an expression. I''ve seen this problem before.

Administrator [Syncfusion]
Replied On November 1, 2005 07:09 PM UTC

Where are you seeing these results? If I open \Essential Studio\\Windows\Calculate.Windows\Samples\DataGridCalculator,and enter this formula into cell B4, it comes back with the value of 2. =countif(a1:a3, ">1")

Byron Tate
Replied On November 1, 2005 08:01 PM UTC

I confirm that the demos work correctly for countif. I apologize for not trying them first. The problem is more complicate because I''m using some unpublished public methods on the engine. I get and use the Parse method like this, as per instructions I got from one of my Direct-trac issues concerning performance for large grids: System.Reflection.MethodInfo ParseFormulaInfo; private string ParseFormula(string formula) { if(ParseFormulaInfo == null) { ParseFormulaInfo = typeof(GridFormulaEngine).GetMethod("Parse", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.InvokeMethod | System.Reflection.BindingFlags.Public , null, new Type[1]{typeof(string)}, null); } object os = null; if(ParseFormulaInfo != null) { os = ParseFormulaInfo.Invoke(m_Engine, new object[]{formula}); } return os.ToString(); } I call my function, ParseFormula with a string which is one of my named ranges preceeded by ''=''. "count(J1:J2)" works OK as the value of the named range. But in this case the value of the named range is: "countif(J1:J2,\">1200\")" the countif statement gives an ArgumentOutOfRangeException, which occured in mscorlib.dll, with added info "Length cannot be less than zero" I understand that I have a non-standard use of the engine here, and it''s working great so far with all my issues that have been posted in direct-trac. I have not ever tried this particular function up till now, and I know I could write my own. So I don''t expect you to spend a lot of time debugging this since you don''t have my complete code setup.

Administrator [Syncfusion]
Replied On November 2, 2005 09:49 AM UTC

The problem is with using quoted strings inside namedranges. These are not being parsed properly(strings are cached before the namedranges are substituted-meaning that the strings inside namedranges are not properly cached). We will have to fix this in our source code. I do not know of a work around for this.


This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon