Distinct Count

I need to distinct count the customer number in Fastreport, How I can do this?

GroupHeader1 <Cust No>
MasterData1 [Cust No, Cust Name, Invoice No, amount]
GroupFooter1 [Distinct Count <Cust No>, Count <No of Invoice>

Best Regards

Leslie

Comments

  • gordkgordk St.Catherines On. Canada.
    edited 6:07AM
    inyour memo in the group footer
    in editmode select the aggregate button and build your aggregate expression.
  • Anu de DeusAnu de Deus Hampshire, UK
    edited 6:07AM
    In the script:

    var LastCustNo : string;
    TotalCustomers : integer;

    procedure OnGroupHeader1.OnBeforePrint; << create this one by double-clicking in the event in the object inspector
    begin
    if LastCustNo <> (<Datasetname."Cust No">) then // << check the syntax here, with other examples, I'm not 100% sure
    inc(TotalCustomers);

    LastCustNo := <Datasetname."Cust No"> // << check the syntax here, with other examples, I'm not 100% sure
    end;

    function GetCustomerCount: string;
    begin
    result := inttostr(TotalCustomers);
    end;

    Then in the page editor, in the MemoView where you have [Distinct Count <Cust No>], simply make its text value exaclty as the next line:

    [GetCustomerCount]

    Should work, with some minimal adjustments.
    I hope it helps

  • edited January 2010
    Dear Anu de Deus ,

    It Work!

    Thank a lot!

    Best Regards

    Leslie :lol:" border="0" alt="laugh.gif" />" alt=">" />

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.