Search code examples
arraysfilemaker

FileMaker Line Delimited Array Manipulation


I have a set of data on a number of companies. For example, the amount of widgets Acme corporation has made. Each record contains the amount made each day, and I have it in a subsummary part so that we can see how many were made for an entire month, and compare all of the different company's outputs.

What I need to accomplish is adding in a filter to remove some of the companies from the list if their monthly production is under a certain amount. We needn't bother ourselves with Acme corporation if they only produced 2 widgets the whole month when the average is 20.

The way I'm currently trying to work it is to add up all of the values in an custom made array. I'm using two custom functions so far. FindInList will tell me if a company already exists in the line delimited array and ArrayValue will tell me what the value is in an array if I provide the index. What I am lacking is the ability to take this list and edit a line in the array when I provide an index. If I get that, then I can easily add up all of the company's monthly totals and find out which are below a certain point, then filter them out. Anyone know how to do that?

I am not tied to this method. If anyone knows a better way to accomplish this task I would be more than happy to consider it.


Solution

  • IMHO, the simplest method would be to sort the records by company, descending + reorder by summary field (total of amount). Then do:

    Go to Record/Request/Page [ First ] 
    Loop 
        # IF CURRENT GROUP DOESN'T MEET THE CRITERIA... 
        If [ GetSummary ( YourTable::sTotalAmount ; YourTable::Company ) < 0 ] 
            # ... OMIT REMAINING RECORDS 
            Omit Multiple Records [ No dialog; Get ( FoundCount ) - Get ( RecordNumber ) + 1 ] 
        Else 
            # JUMP TO NEXT GROUP 
            Go to Record/Request/Page [ No dialog; Get ( RecordNumber ) + GetSummary ( YourTable::sCount ; YourTable::Company ) ] 
        End If 
        Exit Loop If [ Get ( RecordNumber ) = Get ( FoundCount ) ] 
    End Loop 
    

    Note:

    • sCount is a summary field defined as: Count of [ any field that cannot be empty ].
    • In this example, 0 is the minimum sub-summary amount for a group to be shown in the report.

    Credit: adapted from the 'Fast Summaries' technique by Mikhail Edoshin.