Unique Count Flowfield

Datapac
Datapac Member Posts: 97
Hi,
I'm having a problem with a flowfield where I'm trying to count the number of unique occurances of a field given certain criteria.

Eg: Count of Boxes for an Order
Box Details Table
Box No. Item Order No
A I1 SOR100
A I2 SOR100
B I3 SOR100
C I4 SOR100
C I5 SOR100

Using a flowfield on the Order table I want to show that the items are packed in 3 boxes. However, when I try to add a flowfield for this it keeps giving a count of 5 for the example above.
I want to just count unique occurances of Box No.

Flow field formula is as follows:
Count("Carton Contents" WHERE (Sales Doc. No.=FIELD(No.)))

Any ideas?

Answers

  • Marije_Brummel
    Marije_Brummel Member, Moderators Design Patterns Posts: 4,262
    You'll need C/AL code for that.

    You can populate a temp. table what has the key with the unique fields and count the records.

    There are examples of this on the forum.
  • Datapac
    Datapac Member Posts: 97
    Thanks Mark,
    Was afraid of that! Might just bite the bullet and create a Box Header and Box Lines table instead, and make the flowfield count the records in the Box Header table.