3 Replies Latest reply on May 20, 2014 2:57 PM by philmodjunk

    How to create a categorical field?

    terrypink

      Title

      How to create a categorical field?

      Post

           Can someone please tell me how to create a variable that has a drop down list of options, such as Yes, No, and Maybe? 

            

           Would that be a text field or a number field?

            

           If I wanted to be able to have Yes mapped to the number 1, and No mapped to 2, and Maybe mapped to 3, how would I do that?

           Thanks so much!

        • 1. Re: How to create a categorical field?
          philmodjunk

               A value list would be defined in Manage | value lists, an option you can select from the File menu.

               This can be a list of custom values or values taken from a field in a table.

               You have two basic options--both a bit different from what you may be used to doing with other applications:

               You can set up a table with 3 records and two fields: Put your numeric values in one field and the text values in a second field. Then, by selecting the "use values from a field" option, you can select the number field for field 1 and by selecting the "also use values from" option, select the text field for field 2. You can then select the "only show values from second field" option.

               Since this may seem like a lot of work just to get 3 values in your value list, you might, instead use a custom value list of just the text values and define a calculation field that stores the numeric values from what text value is selected:

               Case ( DropdownField = "yes" ; 1 ;
                          DropdownField = "no" ; 2 ;
                          DropdownField - "maybe" ; 3 )

               

                    Would that be a text field or a number field?

               In FileMaker it may not make much difference, but I make it a "best practice" to put strictly numeric data into fields of type number and text or text and number data into fields of type text. Thus, it would depend on which option you choose for how you set this up.

          • 2. Re: How to create a categorical field?
            terrypink

                 Thank you for your help, Phil.  I tried your second approach, but when I tried to create the calculation variable based on a value list called Boolean, and used the formula:

                  

                 Case (Boolean="No"; 0

                 {; Boolean = "Yes"; 1

                 {; Boolean = "Maybe"; 2}

                 )

                  

                 It comes up with the message "The specified field cannot be found"

                  

                 Any help would be appreciated!

            • 3. Re: How to create a categorical field?
              philmodjunk

                   You need to refer to the name of the field that you format with the value list, not the name of the value list.

                   And there should be no {  } in this expression.

                   And the field that you format with the value list cannot be the field you define as a calculation field with this expression.