January 6, 201313 yr Hello I need to make a calculation that can choose a random number from 1 to 30 then place the number in a field named 1st number and then choose another number from 1 to 30 but not use the one used in the 1st number field.This would need to happen 5 times Below is the way it would be done but I don't know how to calculate it. EX. Get a random number from 1 to 30 FM picks 27 27 is placed in the field 1st number. Get a random number from 1 to 30 but doesn't use the contents of field 1st number (27) FM then picks 3 3 is placed in the field 2nd number. Get a random number from 1 to 30 but doesn't use the contents of field 1st number (27) or 2nd Number (3) FM then picks 11 11 is placed in the field 3rd number. Get a random number from 1 to 30 but doesn't use the contents of field 1st number (27) or 2nd Number (3) or.3rd number (11) FM then picks 7 7 is placed in the field 4th number. Get a random number from 1 to 30 but doesn't use the contents of field 1st number (27) or 2nd Number (3) or 3rd number (11) or 4th number.(7) FM then picks 10 10 is placed in the field 5th number. The final numbers are then 27 3 11 7 10 They are each placed in the above mentioned fields. I have enclosed a filemaker 12 file that does the above but doesn't fix the problem of duplication This is where I need help with this calculation. Thank you very much for your help and consideration Random day of the month.fmp12.zip
January 6, 201313 yr Solution Basically, there are two ways you could accomplish this: 1. Loop: select a random value; if the value hasn't been selected before, add it to the list of selected values; exit the loop when the list contains 5 values. 2. Define a table of 30 records; start by showing all records; then go to a random record and omit it; repeat the last step 5 times, then show omitted. --- P.S. I am not sure what you intend to do with these 5 numbers once you have them, but you could probably find a better way to hold them than 5 identical, numbered fields. Edited January 6, 201313 yr by comment
January 6, 201313 yr Author Thank you for your information I would like to tackle this problem with your solution number 1. But I don't know how to script it. I basically want to choose a random number 1 to 30 in this case but not consider the contents of those 5 fields when filemaker is choosing the random number. I need help to write that . I don't understand how to do it. Thanks
January 6, 201313 yr At the end of this script: Loop Set Variable [ $item ; Int ( Random * 30 ) + 1 ] If [ IsEmpty ( FilterValues ( $item ; $values ) ) ] Set Variable [ $values ; List ( $values ; $item ) ] End If Exit Loop If [ ValueCount ( $values ) ≥ 5 ] End Loop you will have a $values variable containing a list of 5 distinct random values in the range of 1..30. You can then proceed to distribute them as you wish.
January 6, 201313 yr Author I sorta get it . I don't have any experience with variables . I made what you gave into a script but it didn't do anything. I wish I knew how to implement it into the file I posted. Because without that I don't know what I am doing. I feel badly about that but thats the way it is. If someone can make this script work for the example I posted please do so. I can understand better when something works and it is in its proper place in the way it should be. Thanks
January 7, 201313 yr Unfortunately, I cannot look at your file because it's in version 12. Perhaps the attached might help you. Random5.fp7.zip
January 7, 201313 yr Here is comment's method incorporated into your sample, along with an implementation of your Final Numbers and total numbers fields. Random day of the monthMod.fmp12.zip
January 7, 201313 yr Author Thank you so much. I have been experimenting with the files. I am so inspired I can't tell you. This is a lot for me to use and learn. Great thanks to you both. Hart
Create an account or sign in to comment