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.

# Countif function doesn't parse

Hi,

I'm working with the CalcQuickBase object, it works fine, but I'm currently having a hard time parsing the CountIf function
I'm very new to the Calculate object.

example Code :

var cq=new CalcQuickBase();

var checkValue=">1407";

cq["A"]="1407";
cq["B"]="1408";
cq["C"]="1407";
cq["result"]=cq.ParseAndCompute(" = CountIf ( ( A , B , C ) , checkValue )");

I also tried " = CountIf ( ( A , B , C ) ,\">1407\")"

This doen't work. Probably I'm doing something wrong when specifying my list.

I tried also this one:

var engine=cq.Engine;

var result=engine.ParseAndComputeFormula("= CountIf ( ( A , B , C ) , checkValue )");

but no success

On the other hand the Count works fine:
var result=engine.ParseAndComputeFormula("= CountIf ( A , B , C )");

Can you point me into the right direction with this?

5 Replies

MA Mahendran Annamalai Syncfusion Team January 8, 2016 01:35 PM UTC

Hi Carron,

Thanks for using Syncfusion products.

By default, the values from the particular key in CalcQuick are returned as an object value. This value can be converted to a string using ToString() method. As separate support is not provided to format the result of the CalcQuickthe result is formatted using int.Parse, double.Parse and decimal.Parse. Refer the below code example.
 CalcQuick calculator = new CalcQuick(); //Reassigning the formula if changed calculator["A"] = this.value1Text.Text; calculator["B"] = this.value2Text.Text; calculator["C"] = this.formulaText.Text;             //Used to recalculate the all formulas in CalcQuick calculator.SetDirty(); //Formatting the result string after parsed as double this.resultText.Text = double.Parse(calculator["C"].ToString()).ToString("#,##0.00");

Regards,

Mahendran.A

CS Carron Schilders January 9, 2016 06:41 PM UTC

Hi,

Thanks for your quick response. It's probably me, but how does this relate to my question about the Countif?
I really can't get it to work. In your code example you don't use the ParseAndCompute method. i tried that but with no luck.

I'm having trouble in how to use the countif with the CalcQuickBase object.

Do you have an example with CountIf and calcQuickBase for me?

With kind regards,

Carron

MA Mahendran Annamalai Syncfusion Team January 11, 2016 02:35 PM UTC

Hi Carron,

As we have checked with excel and calcquickbase source, we can’t able to calculate the Countif formula as like you  CountIf ( ( A , B , C ) , checkValue )" mentioned. See reference link below.

Linnk : https://support.office.com/en-us/article/COUNTIF-function-e0de10c6-f885-4e71-abb4-1f464816df34

We need to add additional control like grid then only so that we can set required values in cell and pass this cell range as argument. We have provided sample for this by using calcEngine in dashboard. Please refer the sample location.

Sample Link : C:\Users\.................. \AppData\Local\Syncfusion\EssentialStudio\..........\Windows\Calculate.Windows\Samples\Data Grid Calculator Demo\CS.

Please let us know if you need any further assistance on this.

Regards,
Mahedran.A

CS Carron Schilders January 21, 2016 03:39 PM UTC

Hi Mahendran,

I've attached a zip file with two screenshots in it taken from the DataGrid Calculation Demo CS
sample. As you can see I get an error (#NAME?) when I use the simple CountIf function.

I can't get it to work.

With kind regards,

Carron

Attachment: CountIf_db97e6d1.zip

JP Jagadeesan Pichaimuthu Syncfusion Team January 22, 2016 12:36 PM UTC

Hi Carron,

Thanks for the update.

We had analyzed the issue with “CountIf function does not parse” in the Dashboard sample. You can solve the CountIf parse problem by using the formula like “=CountIf(A1:A7,">5")”.  Please find the screenshot with Syncfusion control and MS Excel.

Attachment: