Count in FlowField - display the results in a Group Footer section

Hello all!

Im new here and also to Navision scene. My problem is the following:

I have created a field in a table, type FlowField with the CalcFormula = Count(“Domestic Declaration Line” WHERE (Type=CONST(Purchase),Posting Date=FILTER(01/11/12…30/11/12),VAT Registration No.=FIELD(VAT Registration No.)))

Now, this field in the Table, named “Count Purchase” has to be displayed in a report wich create some totals from this table based on some filters, etc.

I assigned a global variable cntEntries to this field from the table and I have put it in the Group Footer section of the report.

In the PreSection of the Group Footer i’ve put: cntEntries := DomesticDeclarationLine.“Count Purchase”;

Where DomesticDeclarationLine is my table and Count Purchase is my field created as FlowField wich does some counting based on the above CalcFormula.

My problem is it displays 0 all the time, although if I open the form related to that table, the counting is correct.

Where is could be the problem?

Thanks a million for any help!

Before assigning the value of the FlowField, you have to use CALCFIELDS statement:

DomesticDeclarationLine.CALCFIELDS(“Count Purchase”);

cntEntries := DomesticDeclarationLine.“Count Purchase”;

And also you should move in OnAfterGetRecord trigger: if you need to perfom any totalization on this field, you can set it in TotalFields property of the DataItem and use directly “Count Purchase” in GroupFooter sections.

Thanks alot for the reply!!

It isnt working, it outputs the same result for for all the entries.

I want to better explain the situation:

I have a GroupFooter in a report with has a GroupTotals propery by a unique VAT number and has TotalFields for the Amount corresponding to each VAT number. All this date comes from Domestic DeclarationLine table in wich I have multiple Purchase type entries for each VAT number, thus the necessity of a totalling. I needed to COUNT those Purchase entries based on certain date filters and VAT Number. And it does well at the table level. But when I put it in the Group Footer section of the report, it just outputs wrong numbers…even though I’ve put CALCFIELDS where you directed me to put em.

Ok, now it’s more clear: if you need to manage a variable date filter, “Posting Date=FILTER(01/11/12…30/11/12)” in the CalcFormula will not work properly, you need also to add on the table where you added the other field a FlowFilter of type date and replace that part with “Posting Date=FIELD(Date Filter)”.