Skip to Content

How do I count if a number appears once per group in an array

I'm running a report where I need to count if integers have appeared in an array; however, I can only count them once per group.

Therefore if I'm looking for 3 in the following groups.

Tim
1,2
1,3,4
3
3,6,7

Beth
1,3
2
7,8

Luke
1
2,4
1

I would get a count of 2 because it's appeared in 2 groups despite the fact that it's appeared more than once in the one group.

Thanks!

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • May 01 at 08:10 PM

    A simple way to do this might be to add a flag that indicates whether the number has been found for the current group.

    In the group header, you would place a formula like this to reset the flag to indicate that the value hasn't been found yet.

    BooleanVar valueFound := false;
    " "

    Then, in your formula that does the count, you would do the following:

    At the top of the formula add:

    BooleanVar valueFound;

    Then, in the part where you check to see if the value is in the array, you might do something like this:

    if <value> in <array> and not valueFound then (
    <count> := <count. + 1;
    valueFound := true;
    );

    This way the count would only be incremented if it hadn't already been found for this group.

    -Dell

    Add comment
    10|10000 characters needed characters exceeded