4 Replies Latest reply on May 16, 2016 7:11 AM by beverly

    search within 50%

    biggestbossfan

      Good afternoon,

       

      I am busy evaluating FileMaker Pro for an application. I need to query a field, but don't want the exact number to be queried. So if the number I'm looking for is 100, I'd like to return anything from 50 to 150.

       

      If this makes sense, it it possible to do?

       

      Cheers

        • 1. Re: search within 50%
          beverly

          You might create a "range".

           

          Let (

          [ myvalue = 100 // this could be supplied as a parameter in a custom function, perhaps

          ; mypercent = .50 // this is 50% & the percent could also be passed

          ; lower = myvalue * mypercent

          ; upper = myvalue * ( 1+ mypercent )

          ; result = lower & "..." & upper

          ]; result // values to be returned as TEXT

          )

           

          Then use the result in a scripted find.

           

          beverly

          • 2. Re: search within 50%
            erolst

            Use the range operator, e.g. in a script:

             

            Enter Find Mode [ no pause ]

            # [ yourGlobalField contains a number ]

            Set Field [ YourTable::yourNumberField ; Let ( n = YourTable::yourGlobalField ; n * .5 & ".." & n * 1.5 ]

            Set Error Capture [ on ]

            Perform Find [ no restore ]

             

            Manually it works the same, except you don't use quotes and must calculate the bounds yourself …

            • 3. Re: search within 50%
              biggestbossfan

              Thanks very much beverly,

               

              Please bear with me, not having any experience in the product and the last time I did any coding was in 1976 in Ditran.

               

              Where would I be entering the information? Is this in a script and if so is there a tutorial I could look at so as not to waste your time in getting this set up?

               

              Regards

              • 4. Re: search within 50%
                beverly

                I would script a find.

                 

                Where are you getting the 'mid-value'? where are you getting the percent? I might use global fields to enter those values (which would be session/user specific)

                 

                Then I would take those values, and put into a script.

                 

                Enter Find mode

                Set field ( myField ; ... here is where the Let() is used ) // instead of the values hard coded, you can use the global fields

                Perform Find

                 

                (and I believe erolst had similar answer)

                 

                beverly