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:18AM
    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:18AM
    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