8 Replies Latest reply on Jun 29, 2011 11:49 AM by philmodjunk

    Counting Quesiton Answers

    ZoocMan85

      Title

      Counting Quesiton Answers

      Post

      Hey Everyone,

       

           I have 5 questions on my one form i designed and im trying to make a calculation by counting the answers. So pretty much i want the word YES to have the value of 1 and No to equal 0. Then in the end count how many were the total. What is the easiest way of doing this?

        • 1. Re: Counting Quesiton Answers
          philmodjunk

          Put your 5 questions into a related table and display the questions with anwer fields in a portal.

          Define the yes/no field as number field. Format the field as a check box group and specify "1" as the only value. Resize this field so that only the check box, not the one is visible. Put "Yes" next to it as layout text. (A selected checkbox = "yes" a cleared checkbox = "no".)

          Now, a calculation field in your parent table can use Sum ( RelatedTable::Answer ) to count the number of "yes" answers.

          (Note: with boolean data formatting, a 1 can be displayed as "Yes" and a 0 can be displayed as "No"--which may be useful with the above set up for certain reports.)

          • 2. Re: Counting Quesiton Answers
            ZoocMan85

            Phil you lost me bud. I have the 5 questions in the same table. On my application page where these questions are answered they have yes or no drop down list. This drop down list is a value list. On my results page where i want these questions to be displayed and the questions answers counted... I copied and pasted them from my application page. Turning the browse mode option off on them so the users cant change the question answers on the results page. How do i proceed from there to make this work?

            • 3. Re: Counting Quesiton Answers
              philmodjunk

              What I am suggesting is that you use manage | Database | Tables to define a new table. Click the fields tab and define fields for this new table to include a text field for the question, a number field for the response and a foreign key field to link back to your original table. If you don't already have one, define a number field in your original table and set it up in field options as an auto-entered serial number, then link this serial number field to the "foreign key" field in the related table. You'd need a script to set up a group of related records for each new record created in your original table. There are a number of threads here that discuss using FileMaker for surveys that go into this concept in much greater detail. Normally, you end up with several tables, one for the respondants, One for the maste list of questions and one for the responses.

              If your database has already been used to collect your results, then a much less flexible approach would need to be devised to count your "yes" answers here.

              • 4. Re: Counting Quesiton Answers
                ZoocMan85

                I get what your saying but their is already data within the database... There is no easier way of doing this?

                 

                • 5. Re: Counting Quesiton Answers
                  ZoocMan85

                  Is it possible to define each question within a script and have in the script yes= 1 and then have it set as a number field. Then have one calculation form to add up the five questions ?

                  • 6. Re: Counting Quesiton Answers
                    philmodjunk

                    It can be done, it will just take more work and any future changes to your questions, will require a lot more work.

                    Add calculation fields, cYes1, cYes2, cYes3... (one for each question field) defined like this:

                    QuestionField1 = "Yes"

                    select Number as the result type. Just refer to a different question field in each calculation field's expression until you have one for reach question field.

                    Then add one more calculation field to count your yes responses:

                    Sum ( cYes1 ; cYes2 ; cYes3 ; ...) //list all the cYes calculation fields here.

                     

                    • 7. Re: Counting Quesiton Answers
                      ZoocMan85

                      What i did phil was change the question edit boxes to numbers like you suggested. I made a new value list that says Yes=1 No=0. I then made a calculation field and added all the questions together. It works great. Only thing is you see =1or =0. To me it doesnt matter. So i took your original suggestion. Any ideas on how to hide the =0 or =1 ?

                      • 8. Re: Counting Quesiton Answers
                        philmodjunk

                        You don't need the =. Just the 1 in the Yes value would do.

                        No way to hide that value though except possibly by making the field narrow enough that the 1 isn't visible, but the "yes" is.