Jump to content
Server Maintenance This Week. ×

Out of Curiosity, Is it possible in a lookup to have a random placement


hownow

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

Recommended Posts

By this I mean

 

If I had a sentence.

 

" I love the color  .........."

The relationship word is color

but the possible answers might be

red, blue, green , yellow orange white , maroon.

 

Can this be done somehow?

 

The lookup may have a random answer within a list...

 

Not sure what call this.

 

 

 

 

Link to comment
Share on other sites

I'm not absolutely sure what you're trying to do. I think you want to select a random record from another table. If that's the case, here's how I would probably do it. I'm going to work with a Sentences table and a Colors table.

 

Create a cartesian product relationship between the two tables. This relates all of the records in one table to all of the records in the other table. Normally you create a equals relationship where the match fields must equal each other and the symbol in the popup menu between the match field selection lists is an equal sign. For a cartesian product relationship the match fields don't really matter and you select the "x" symbol in the popup menu. See http://help.filemaker.com/app/answers/detail/a_id/5463/~/using-the-cartesian-product-relationship-in-filemaker-profor more information about it.

 

Now that you have the cartesian product relationship, you can create a calculation that will, from Sentences, choose a random record's field's contents in Colors:

Let(
  [
    _count = Count(Colors::id);
    _random = Int( Random * _count ) + 1
  ];

  GetNthRecord( Colors::color; _random )
)

Check out http://sixfriedrice.com/wp/creating-random-numbers-in-filemaker-pro/for a nice custom function that'll do a better job at generating random numbers.

 

Thanks,

Chuck

Link to comment
Share on other sites

FYI, FMI have fixed the Random function so that in can no longer return 1. That was waaaaaay back in v10.0v3.

 

Thanks for the information. I was unaware of that.

Link to comment
Share on other sites

  • 2 weeks later...

I don't quite get it. I made a file with a drop down box and a relationship to see if there is a way to do this with random birds of the same name. If you try to place a bird name you will always get the same lookup.

I am trying to get a random of the same bird, as in the example i am uploading

Can someone help me get this right with this file.

Thanks

 

Birds for FMFORUM RANDOM.fmp12.zip

Link to comment
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.