dbTalk Databases Forums  

Assigning Numbers

comp.databases.filemaker comp.databases.filemaker


Discuss Assigning Numbers in the comp.databases.filemaker forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Tom Street
 
Posts: n/a

Default Assigning Numbers - 08-09-2003 , 10:00 AM






I am relatively new to FM and am trying to figure out a solution to
this problem;

A database has x number of records all with the assigned number of 1.
What I'd like to do is to randomly replace each number with a new
number that would be within the range of 1.001 to 1.xxx (where x is
the last record.)I know about FM's Random function and that seems to
hold some promise but is there a way to set lower and higher limits to
it?

Thanks,
Tom Street
tomstreet (AT) alltel (DOT) net

Reply With Quote
  #2  
Old   
Shadenfroh
 
Posts: n/a

Default Re: Assigning Numbers - 08-09-2003 , 10:26 AM






Imagine two fields, "High" and "Low", which include your high and low
limits. (You can replace one or both of these fields with a calculated
result, like status ( currentrecordcount ) .)

To set a random number with an upper limit, set field to "High * Random"
To set a random number between upper and lower limit, set field to "Low +
( ( High - Low ) * Random)"

Try that, then "tweak" the results to what you want. F'rinstance, you
probably want to round or truncate the number to a certain number of digits.

If you don't want duplicate numbers, try this: set the random number into a
field, then sort by that field and use the Replace function to number the
records sequentially in their new, random order.

--
Shadenfroh
shadenfroh (AT) email (DOT) uophx.edu

"Tom Street" <tomstreet (AT) alltel (DOT) net> wrote

Quote:
I am relatively new to FM and am trying to figure out a solution to
this problem;

A database has x number of records all with the assigned number of 1.
What I'd like to do is to randomly replace each number with a new
number that would be within the range of 1.001 to 1.xxx (where x is
the last record.)I know about FM's Random function and that seems to
hold some promise but is there a way to set lower and higher limits to
it?

Thanks,
Tom Street
tomstreet (AT) alltel (DOT) net



Reply With Quote
  #3  
Old   
John Weinshel
 
Posts: n/a

Default Re: Assigning Numbers - 08-09-2003 , 10:58 AM



You can loop through the records, assigning the number to:

Truncate( Lowest + Random* ((Status( CurrentRecordCount) / 1000 ) - Lowest)
, 3 )

....where 'Lowest' is 1.001. If you also need the values to be unique, you
can add a test for that in your loop. One way is to set a global to the calc
above, and then, using a relationship (a self-join) from the global to the
number, test to see if there are any matches. If so, try again.

You might fool around with Round() instead of Truncate(), depending on what
you are looking for.

--
John Weinshel
Datagrace
Vashon Island, WA
(206) 463-1634
Associate Member, Filemaker Solutions Alliance


"Tom Street" <tomstreet (AT) alltel (DOT) net> wrote

Quote:
I am relatively new to FM and am trying to figure out a solution to
this problem;

A database has x number of records all with the assigned number of 1.
What I'd like to do is to randomly replace each number with a new
number that would be within the range of 1.001 to 1.xxx (where x is
the last record.)I know about FM's Random function and that seems to
hold some promise but is there a way to set lower and higher limits to
it?

Thanks,
Tom Street
tomstreet (AT) alltel (DOT) net



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.