tags:

views:

303

answers:

4

I have a table like this:

Application,Program,UsedObject

It can have data like this:

A,P1,ZZ
A,P1,BB
A,P2,CC
B,F1,KK

I'd like to create a layout to show:

Application,# of Programs
A,2
B,1

The point is to count the distinct programs.

For the life of me I can't make this work in FileMaker. I've created a summary field to count programs resetting after each group, but because it doesn't eliminate the duplicate programs I get:

A,3
B,1

Any help much appreciated.

A: 

Since I also generate the data in this form, the solution I've adopted is to fill two tables in FileMaker. One provides the summary view, the other the detailed view.

TheArtTrooper
A: 

I think that your problem is down to dupliate records and an inadequate key.

Create a text field called "App_Prog". In the options box set it to an auto-enter calc, unchecking the 'Do not replace...' option, and use the following calc:

Application & "_" & Program

Now create a self join to the table using App_Prog as the field on both sides, and call this 'MatchingApps'.

Now, create (if you don't alread have one) a unique serial number field, 'Counter' say, and make sure that you enter a value in each record. (Find all, click in the field, and use serial number option in'Replace Field Contents...')

Now add a new calc field - Is_Duplicate with the following calc...

If (Counter = MatchingApps::Counter; "Master Record" ; "Duplicate")

Finally, find all, click in the 'Application field, and use 'Replace Field Contents...' with a calculation to force the auto-enter calc for 'App_Prog' to come up with a value.

Where does this get you? You should now have a set of records that are marker either "Master Record" or "Duplicate". Do a find on "Master Record", and then you can perform your summary (by Application) to do a count of distinct application-program pairs.

Dycey
I agree that for the purposes of the report using just App and Program is not unique to identify a row. Another program produces the data that's going into FileMaker so it was easier for me to fill a second table where App,Prog do uniquely identify a row for the purposes of this summary layout.
TheArtTrooper
A: 

If you have access to custom functions (you need FileMaker Pro Advanced), I'd do it like this:

Add the RemoveDuplicates function as found here (this is a recursive function that takes a list of strings and returns a list of unique values).

In the relationships graph, add another occurrence of your table and add an Application = Application relationship.

Create a calculated field in the table with the calculation looking something like this:

ValueCount(RemoveDuplicates(List(TABLE2::Program)))

You'll find that each record will contain the number of distinct programs for the given application. Showing a summary for each application should be relatively trivial from here.

DisplacedAussie
A: 

I think the best way to do this is to create a separate applications table. So as you've given the data, it would have two records, one for A and one for B.

So, with the addition of an Applications table and your existing table, which I'll call Objects, create a relationship from Applications to Objects (with a table occurrence called ObjectsParent) based on the ApplicationName as the match field. Create a self join relationship between Objects and itself with both Application and Program as the match fields. I'll call one of the "table occurrences" ObjectsParent and the other ObjectsChildren. Make sure that there's a primary key field in Objects that is set to auto-enter a serial number or some other method to ensure uniqueness. I'll call this ID.

So your relationship graph has three table occurrences:

Applications::Applicaiton = ObjectsParent::Application

ObjectsParent::Application = ObjectsChildren::Application, ObjectsParent::Program = ObjectsChildren::Program

Now create a calculation field in Objects, and calculating from the context of ObjectsParent, give it the following formula:

AppCount = Count( ObjectsChildren::ID )

Create a calculation field in Applications and calculating from the context of the table occurrence you used to relate it to ObjectsParent with the following formula:

AppCount = ObjectsParent::AppCount

The count field in Objects will have the same value for every object with the same application, so it doesn't matter which one you get this data from.

If you now view the data in Applications in list view, you can place the Applications::Application and Applications::AppCount fields on the layout and you should get what you've requested.

Chuck