# Confusing Calculation

This topic is 6628 days old. Please don't post here. Open a new topic instead.

## Recommended Posts

hello all ... i work with a photography company and i am looking to create camera cards ... i am currently using filemaker as my primary database program ... The "Camera card" is an 8.5x11 sheet that will display 9 records on it ... this is relativly simple... but here is the catch ... i need the records to be sorted very oddly before printing ... see the attached three images to better explaing what i need. Lets just say that my database has 27 records for sanity's sake. on the cards i need the records to be printed "stacked" what i mean is that on page 1 the first record should print is the first of the nine slots. (see attached) however ... the second record needs to be in the first place on page two. ,, likewise for the third record. needs to be in the first place on page three. This may be all two confusing ... but i am totally lost .... the only way i see this possible it to create a sort field ... then fill it with a calcualted result. that calculation being something like "number of records" divided by 9 - that will get me the total number of pages that will be used in the printout ... then fill with a serial number starting at 1 and increasing by the total number of pages .... maybe thats not the way to do it ... please let me know if you have any ideas

-----------------------------------------------------------

-----------------------------------------------------------

-----------------------------------------------------------

-----------------------------------------------------------

-----------------------------------------------------------

-----------------------------------------------------------

##### Share on other sites

You will need a field to serialize your records. Let's call it "SN". And then another one for a page count. Let's call it "Pages" (which contains the value of current record count divided by 9). Assume that SN contains the photo numbers. You can make a sort field "SortOrder" with this calculation:

9*Mod(sn-1;Pages)+Int((sn-1)/Pages)+1

Then sort on the SortOrder field.

This should work when the number of records is an exact multiple of 9, but I don't know how you want to handle less than exact multiples.

<<Edit: I had the formula backwards. Fixed it.>>

##### Share on other sites

I hope Bob doesn't aim that cannon at me for this.

You can replace Int((SN - 1)/9) with Div( SN - 1; 9 ), and there is a missing ending parenthesis.

##### Share on other sites

i need 3 things then ... How can i get "(which contains the value of current record count divided by 9)"

how do i get the SN field to contain the Current record number

how can i automaticly add (how ever many) records needed to make it exact multiples of nine?

##### Share on other sites

Hi Queue,

Actually, I realized after I posted, that the formula I gave would give the picture sequence, 1, 4, 7, 10, 13, 16... etc., which is not the same as the sort order which is in fact 1, 10, 19, 2, 11, 20... etc. I edited the formula in the previous post before I saw your reply. Still being new to FM7, I wasn't familiar with the DIV function.

##### Share on other sites

Tallboy, you can do this with a script:

```**Add records to make exact multiple of 9

Loop

Exit Loop If [  not  Mod ( Get ( FoundCount ) ; 9 ) ]

New Record/Request

End Loop

** Count pages

Set Field [ Pages; Get ( FoundCount )/9 ]

**Set the SN field Equal to the record number

Replace Field Contents [ sn; Replace with calculation: Get ( RecordNumber ) ] [ Update Entry Options ]

```

##### Share on other sites

This topic is 6628 days old. Please don't post here. Open a new topic instead.

## Create an account

Register a new account