Calculate sum in script in ABBYY Flexicapture - abbyy

I would like to perform the function of a Calculate Sum rule with a Script rule in ABBYY Flexicapture, because I want to only perform the calculation based on evaluation of an if statement.
I have tried the following in a C# script rule:
IFields AllTaxes = Context.Field("cu_location_taxes").Rows;
which gives me the error "Field is not a table."
I have also tried
IFields AllTaxes = Context.Field("cu_location_taxes").Children;
which gives me the error "Cannot access fields not specified in rule settings." Even though I have added the repeating group cu_location_taxes to the c# script rule.
Once I am able to get them in some kind of array or list or IFields variable, I would like to sum the children values in some way. I am open to doing this with JScript or C#.

The reasons of the errors you are facing can be found in ABBYY FlexiCapture Help.
In the description of IField class you can find the following descriptions of properties:
Rows - A set of table rows. Unavailable for non-table fields.
Well, it seems to be that "cu_location_taxes" is not a table. You said, it is a repeating group.
Children - Child items of the field (cells for tables). Unavailable in script rules.
But as I understand, you are exactly using script rules.
To achieve correct results try to use Items property exactly of the fields that you are summing.
For example, you have a repeating group that contains number fields field_1 and field_2. And you want to calculate the sum of all field_1 instances.
Then you can use the following code (JScript):
sum = 0
for (i = 0; i < this.Field("field_1").Items.Count; ++i)
sum += this.Field("field_1").Items.Item(i).Value
Also do not forget to add the field_1 in available fields of your rule settings.
Hope this will help.


Multiple datasets Count with IIF in SSRS

I am trying to write an expression in SSRS which counts only specific data using IIF. I found the following solution:
=Sum(IIF(Fields!Program.Value = "FC", Fields!QuantityToShip.Value, 0))
The code above works but only when there is ONE dataset, while I have several.
Here is the code I wrote:
I get the aggregation error:
Textbox refers directly to the field ‘Mgroup’ without specifying a dataset aggregate
I added a sum:
Still getting the same error.
Why is that?
What can I put instead of Sum? All I need is to count how many groups named 303 I have.
The expression you used has some sintax errors. The Count function only aggregate from the scoped Dataset.
Try this:
Let me know if this helps you.

Parameter Value to select project number range

I have a parameter asking the user if they would like to "only" include project numbers below 5000.
If they say yes, then I need the parameter to adjust the project field to be <=5000. If they say No, then the project number field should be <=99999999.
I am not sure how to accomplish this, right now I have a dataset where project number = #projnum, and I have #projnum parameter with two values of Yes and No.
I attempted to put an expression on the dataset properties under that specific parameter as:
=iif(Parameters!projnum.Value=1, <9999, <9999999999)
but I get a syntax error when using the < sign. It will work with just a number.
Sorry, new to SSRS and cannot figure this one out.
Why not change your dataset query to use <=:
FROM YourTable
WHERE ProjectNumber <= #projnum
Then adjust your parameter values to the range values:

LookUp not matching properly

So, I have a problem in Report Builder that is just driving me absolutely crazy.
I have two dataset; one called DS_Grades and the other DS_Pupils. I want to do a simple LookUp based on PupilID, a field that is in both datasets, and return a grade from DS_Grades into a Matrix based on DS_Pupils.
The formula I am using is:
=LookUp(Fields!PupilID.Value, Fields!PupilID.Value, Fields!Grade.Value, "DS_Grades")
I have confirmed that:
1) DS_Grades has the right PupilIds
2) There are actually values in the Grades field
3) Both PupilID fields (I.E. in both datasets) are definitely Integers and not text.
Moreover, if I add a calculated field to DS_Grades called "test" and populated with the value 208301, which is a valid PupilID, then I can enter the below formula and it works fine:
=LookUp(208301, Fields!test.Value, Fields!Grade.Value, "DS_Grades")
So, the LookUp itself must be matching properly, which means that the PupilID fields must be causing the problem, but I have quintuple freaking checked them and they definitely have the right values, in the right format. I am at a total loss as to why SSRS thinks that they don't match.
Help please!
Got it! Some filtering was at Dataset Level (instead of query where I normally do it) that was throwing the whole thing out of joint. Removed that, and it's fine.

IN(Item, Set) in a calculated field dataset

i am trying to create a calculated field in a dataset where i need to use the experssion IN(item, set) to test if 'Covergate Type' field is equal to one of the below values:
Contractors All Risks
Erection All Risks
PI A&E Single Project
Single CGL
Ive tried to write:
IN(Coverage Type,"Cargo Contractors All Risks","Erection All Risks","PI A&E Single Project","Single CGL")
but it is not working.
Can any one help me how to write the syntax of IN expression?
You can use IIf here with the various checks in a calculated field; there is no real IN equivalent in SSRS without custom code:
=IIf(Fields!CovergateType.Value = "Cargo"
or Fields!CovergateType.Value = "Contractors All Risks"
or Fields!CovergateType.Value = "Erection All Risks"
or Fields!CovergateType.Value = "PI A&E Single Project"
or Fields!CovergateType.Value = "Single CGL"
, true
, false)
Which will return a boolean value depending if it meets your requirement or not.
Change the field name/return expressions as appropriate for your requirements.
Edit after comment
You can definitely use this as a Calculated Field in a Dataset.
Say we have a simple query to generate a sample Dataset:
Now, add a Calculated Field with the expression above:
This can then be used as a normal column anywhere in the report, or even in subsequent Calculated Fields in the Dataset:
Still not sure what you mean by the IN function in SSRS - I can't see anything in the VB.NET function reference. If you supply a link I can amend the answer, but the first suggestion works fine as you can see.
i just solve my problem by this calculated field formula from inside the dataset:
thank you for your support

add extra column value to a column sum

I have the following issue: I have a report that uses a Dataset as its datasource. The dataset has two tables, one would be the main table, say Employee, and the second table is EmployeePaycheck, so an employee can have several paychecks. I can compute the sum of a column in the second table, say paycheckValue, but what I can't seem to do is also add to this computed field the value of some additional fields in the Employee table, such as ChristmasBonus or YearlyBonus, to see how much the employee was paid at the end of the year.
Without knowing more information on this it will be difficult to answer, but I'll give you a couple things to look for.
First, I would make sure that the fields are of a similar type that will allow for a summary. For example, if one is a string then a summary wouldn't be able to be done without casting or convertingthe value to a number. I'm assuming that the fields are probably number or decimal columns so that is probably not the case.
I'd also check to make sure that none of the values that you are trying to sum are null. I haven't tested this, but I believe that it will not sum correctly if one of the rows has a null value. In this scenario you should just be able to use a formula field to check for the null and if the field is null return 0 instead. Then you can use the formula field in your calculations instead of the field itself.
If neither of these are the case please provide a little more info how you are computing the fields and what is happening when you do it.
Hope this helps.