![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Here's a good one for the group, cause it's kind of tough. *Let's say I've got a database with two tables, one called Contacts and one called Categories. *Categories is used to categorize contacts, so the user can make as many categories as he wants and assign as many contacts as he wants -- a many-to-many relation where the contact pk (a field called IDC) is stored in a list in Categories (a field called IDCs) through a relation we'll call CIDC_GIDCs (that is, the Contact IDC field to the Category IDCs field). My client wants to be able to send lists of contacts to people without access to the database using Excel so recipients can manipulate the data however they need. *There's no problem doing this. *However, she wants to include the categories for each contact in columns so that the rows can be sorted and compared by category. *In other words, she wants an Excel list that might look something like this: Name * * * *Tall * * * * *Senior * * * *Scholarship Jack * * * * *Tall * * * * * * * * * * * * * Scholarship Mary * * * * * * * * * * * * Senior * * * *Scholarship Linda * * * * Tall * * * * *Senior Steve * * * * * * * * * * * Senior Hugh * * * * * * * * * * * * * * * * * * * * *Scholarship Since the lists of contacts she exports are determined by ad hoc criteria, she has to be able to export random found sets from the Contacts table. *If I include a field like List(CIDC_GIDCs::Category), it exports the categories one under the other so that each contact takes up more than one row and it's not sortable. *If I include a field with this calculation substituting tabs for line breaks, it exports without the tabs so that all the categories end up in one field/column (and this wouldn't work in the end, because columns wouldn't line up properly). Instead, I created a bunch of generic category fields in Contacts and wrote a script that parses the categories each time she wants to export a list. *In other words, the Contacts table has a bunch of fields named "Cat1," "Cat2," Cat3" etc. and I use the "Set Field by Name" step to loop through and insert categories on an as-needed basis, then wipe them clean. *The generic fields aren't used to store data -- just to create a spreadsheet-like arrangement out of related data for exporting. Best, -Jahn |
#3
| |||
| |||
|
#4
| |||
| |||
|
|
HI, Grip - Thanks for the input. *I'm not sure I understand this correctly. *I need to have the categories line up in a column, so that if two contacts are in the list being exported and one has the categories blue, green and red assigned while the other has green, orange and yellow, then the total number of categories is five (blue, green, red, orange, yellow) and the first contact would have the columns blue, green, empty, red, empty, empty while the second would have empty, green, empty, empty, yellow. *This has to be the case for all contacts, so that yellow for one is in the same column as yellow for every other. *But I think your calculation only takes into account the categories that are assigned to a particular contact, not all contacts in the current found set. *In that situation, the above spreadsheet of two contacts would list different categories in a single column. Is that right, or am I missing the way it works? |
#5
| |||
| |||
|
#6
| |||
| |||
|
|
Hi, Grip - I'm using FMP 10 Advanced -- I should've said that at the outset. Your suggestion with the variable works like a charm. *Damn, very clean. *Nicely done. *I wish FileMaker had a function that referenced the name of the field in which the calculation is stored -- kind of like the Self function for layout objects -- so that I only had to write the calculation once for each field, rather than adjusting the iteration number each time, but otherwise it's pretty streamlined. Sweet. *Thanks for the help. Best, -J. |
![]() |
| Thread Tools | |
| Display Modes | |
| |