1 2 Previous Next 19 Replies Latest reply on Dec 23, 2012 9:06 AM by jrenfrew

    How do I count the number of a specific response?

    crose

      I have an evaluation situation where the person can select 1 of 4 resposnses (1, 2, 3 or 4).

       

      I need a function that counts the number of 1's, then counts the number of 2's, then counts the 3's and the 4's. Any suggestions on an easy way of doing this?

       

      Thanks in advance!

        • 1. Re: How do I count the number of a specific response?
          beverly

          Can you give us more details on the structure of your database?

          Is this one field with checkboxes?

          Is this multiple fields? (with or without checkboxes or radio buttons?)

          ???

           

           

           

          Thanks,

          Beverly

          • 2. Re: How do I count the number of a specific response?
            comment

            The easiest (and fastest) way is to summarize the responses using a summary field, defined as Count of [Response]. Sort your records by Response, and show them in a list layout with a sub-summary (when sorted by Response) part. Place the summary field in this sub-summary part. If you prefer, you can delete the body part from this layout, so that only summary values are shown.

             

            The same summary field, when placed in a grand summary part, will show the total number of responses.

            • 3. Re: How do I count the number of a specific response?
              crose

              This is a Radio Button response field.   1- Strongly agree; 2 - Agree; 3-Disagree; 4-Strongly Agree.

              I have it so that the number is pulled into another field (only showing the numeric option). 

               

              I thought about doing it in Mulitple fields, but I thought there could be a better way. 

              • 4. Re: How do I count the number of a specific response?
                beverly

                you have seen that you can summarize, as the "total" is not giving you the breakdown.

                 

                You can create 4 calculated fields 1=if(response=1; 1; 0), 2=if(response=2; 1; 0), etc.

                then you can summarize these calculated fields..

                & there are other ways to get this.

                 

                Beverly

                • 5. Re: How do I count the number of a specific response?
                  RayCologon

                  crose wrote:

                  I need a function that counts the number of 1's, then counts the number of 2's, then counts the 3's and the 4's.  Any suggestions on an easy way of doing this?

                   

                  Hi crose,

                   

                  I'm guessing that the kind of thing you're looking for can be achieved fairly easily with a few minor tweaks to a technique we published in the DynamicSummary.fp7 (http://www.nightwingenterprises.com/demos8/demo803.html) demo back around the time of the release of FileMaker 8.

                   

                  FWIW, I'm attaching an example file that shows how you might use the technique for the specific purpose you've described.

                   

                  Two caveats. One is that this approach uses a recursive custom function, so just like a summary field, it will work fine for found sets of moderate size, but for very large sets - not so much. The other is that if you want to install the custom function into your solution you'll need a copy of FileMaker Pro Advanced.

                   

                  Regards,

                  Ray

                  ------------------------------------------------

                  R J Cologon, Ph.D.

                  FileMaker Certified Developer

                  Author, FileMaker Pro 10 Bible

                  NightWing Enterprises, Melbourne, Australia

                  http://www.nightwingenterprises.com

                  ------------------------------------------------

                  • 6. Re: How do I count the number of a specific response?

                    Ray,

                     

                    Thank you for your time and help.  If I may ask, when I look at the

                    (http://www.nightwingenterprises.com/demos8/demo803.html) demo in the DynamicSummary.fp7, why when I change the fieldname "suburb" to "house" do I lose the "Suburb of Residence" summary?

                     

                    I'm wondering the following: where specifically I would make the change so I could change that fieldname for my purposes and the sunnary still stay.

                     

                    I hope I am making sense.

                     

                    Thank you very much again; I am very close to figuring out what I need thanks to you!

                     

                    Sincerely,

                    Adam

                    • 7. Re: How do I count the number of a specific response?
                      RayCologon

                      adamsadow wrote:

                      ...I'm wondering the following: where specifically I would make the change so I could change that fieldname for my purposes and the sunnary still stay.

                       

                      Hi Adam,

                       

                      In the DynamicSummary demo, the name of the field to be summarized is sourced from the System::gFieldName field, so as well as changing the name of the field, you'd have to change it there as well.

                       

                      As you'll have seen, the interface includes a pair of buttons (faux radio buttons at the lower left of the main demo screen) to choose whether the summary will show 'Family Name' or 'Suburb of Residence'. Those buttons are configured (via a Set Field[ ] command) to write the appropriate field name into the System::gFieldName field, so if you want the buttons to work again after you've changed the field name, you'd need to also update the button definition to set "House" rather than "Suburb" into the System::gFieldName field.

                       

                      If you don't need the ability to dynamically switch the target field, then you could dispense with the System::gFieldName field and the radio buttons, and instead supply an explicit field reference in the cDynamicSummary calculation.

                       

                      Regards,

                      Ray

                      ------------------------------------------------

                      R J Cologon, Ph.D.

                      FileMaker Certified Developer

                      Author, FileMaker Pro 10 Bible

                      NightWing Enterprises, Melbourne, Australia

                      http://www.nightwingenterprises.com

                      ------------------------------------------------

                      • 8. Re: How do I count the number of a specific response?

                        Ray,

                         

                        I understand when you say "In the DynamicSummary demo, the name of the field to be summarized is sourced from the System::gFieldName field, so as well as changing the name of the field, you'd have to change it there as well.", but where would I make the change?

                         

                        As you'll have seen, the interface includes a pair of buttons (faux radio buttons at the lower left of the main demo screen) to choose whether the summary will show 'Family Name' or 'Suburb of Residence'. Those buttons are configured (via a Set Field[ ] command) to write the appropriate field name into the System::gFieldName field, so if you want the buttons to work again after you've changed the field name, you'd need to also update the button definition to set "House" rather than "Suburb" into the System::gFieldName field.

                         

                        Where would I find the "Set Field" command?

                         

                         

                        If you don't need the ability to dynamically switch the target field, then you could dispense with the System::gFieldName field and the radio buttons, and instead supply an explicit field reference in the cDynamicSummary calculation.

                         

                        I really don't need the radio buttons, so how would supply an explicit field reference in the cDynamicSummary calculation.

                         

                        Hope I'm not being a pain Ray, thank you again.

                         

                        Sincerely,

                        Adam

                        • 9. Re: How do I count the number of a specific response?

                          Ray,

                           

                          This is Adam Sadow again.  Your "CountResponses.fp7 " may also work for me.  The only problem I am having in my own database when trying to implement your count response is that the function "FieldSummary ( FieldName ; ValueList )" doesn't appear as an option when I try and create the field name as a calculation.

                           

                          Thank you again,

                          Adam

                          • 10. Re: How do I count the number of a specific response?
                            RayCologon

                            adamsadow wrote:

                            I understand when you say "In the DynamicSummary demo, the name of the field to be summarized is sourced from the System::gFieldName field, so as well as changing the name of the field, you'd have to change it there as well.", but where would I make the change?

                             

                            Hi Adam,

                             

                            As written, the demo provides buttons to write the correct values into the System::gFieldName field, so the field itself doesn't appear in the interface. To manually edit it to a value that's different from the ones the buttons set into it, you'd have to first put the field into a layout.

                             

                            adamsadow wrote:

                            Where would I find the "Set Field" command?

                             

                            The Set Field [ ] command for each buttons is in the button definition, so to change it you would need to select the button and choose Format>Button... (the button is a graphic oval/circle object grouped with the cgSuburb_rbtn field, so you'd need to unlock and ungroup them first, in order to select just the button).

                             

                            adamsadow wrote:

                            I really don't need the radio buttons, so how would supply an explicit field reference in the cDynamicSummary calculation.

                             

                            In the demo, the field reference is supplied in two places, as per the two references to the System::gFieldName field in the calculation formula for the cDynamicSummary field - the first reference is supplied as a text literal and the second is enclosed in the GetField( ) function to create a pointer to the field.

                             

                            So, you you were to replace the two occurrences of System::gFieldName with an explicit reference to a field called 'House', the revised formula would read as follows:

                             

                            FieldSummary("House";

                            UniqueValues(SortByText(

                              GetValueSet(House; 1)

                               ))

                            )

                             

                            However, if you have an alternative means of providing a list of all values ocurring in the relevant field in the found set (rather than sourcing them dynamically from the referenced field, as the demo does), you will be able to simply supply a list directly to the FieldSummary function. Eg, where the values for House will only ever be House1, House2, House3 or House4, you could generate the summary more simply with:

                             

                            FieldSummary("House"; "House1¶House2¶House3¶House4")

                             

                            As to whether either of the above suggestions will produce the best or most appropriate solution for your current requirement, that's hard to say without knowing a fair bit more about what it is you're doing, how many records, how many values and so on. Among other things, as I remarked earlier in the thread, techniques that depend on recursive functions are best suited to summarizing moderate-sized data sets.

                             

                            Regards,

                            Ray

                            ------------------------------------------------

                            R J Cologon, Ph.D.

                            FileMaker Certified Developer

                            Author, FileMaker Pro 10 Bible

                            NightWing Enterprises, Melbourne, Australia

                            http://www.nightwingenterprises.com

                            ------------------------------------------------

                            • 11. Re: How do I count the number of a specific response?

                              Ray,

                               

                              Found the main problem I think... you created a custom function which I can't use in FileMaker Pro 8.5. I'll check tomorrow if work has a newer version

                               

                              Adam

                              • 12. Re: How do I count the number of a specific response?
                                RayCologon

                                adamsadow wrote:

                                ...the function "FieldSummary ( FieldName ; ValueList )" doesn't appear as an option when I try and create the field name as a calculation.

                                 

                                Hi Adam,

                                 

                                You may have skipped over the final paragraph of the post to which the CountResponses.fp7 file was attached:

                                 

                                Ray Cologon wrote:

                                Two caveats. One is that this approach uses a recursive custom function, so just like a summary field, it will work fine for found sets of moderate size, but for very large sets - not so much. The other is that if you want to install the custom function into your solution you'll need a copy of FileMaker Pro Advanced.

                                 

                                The FieldSummary( ) function is a custom function that must first be added to each file you want to use it in. Custom Functions can only be added using FileMaker Pro Advanced, so you would need to open your file in FileMaker Pro Advanced and install the function via the menu command File>Manage>Custom Functions...

                                 

                                Regards,

                                Ray

                                ------------------------------------------------

                                R J Cologon, Ph.D.

                                FileMaker Certified Developer

                                Author, FileMaker Pro 10 Bible

                                NightWing Enterprises, Melbourne, Australia

                                http://www.nightwingenterprises.com

                                ------------------------------------------------

                                • 13. Re: How do I count the number of a specific response?
                                  RayCologon

                                  adamsadow wrote:

                                  Found the main problem I think... you created a custom function which I can't use in FileMaker Pro 8.5. I'll check tomorrow if work has a newer version

                                   

                                  Hi Adam,

                                   

                                  No, that's not the problem. Custom functions have been supported as far back as version 7, and the function in the CountResponses.fp7 and DynamicSummaries.fp7 demos will work in version 8.0 or later.

                                   

                                  As per my previous post, the issue is that you need FileMaker Pro Advanced to edit or install a custom function. Once it is installed (in a given file) you can use it with the regular edition of FileMaker Pro.

                                   

                                  Regards,

                                  Ray

                                  ------------------------------------------------

                                  R J Cologon, Ph.D.

                                  FileMaker Certified Developer

                                  Author, FileMaker Pro 10 Bible

                                  NightWing Enterprises, Melbourne, Australia

                                  http://www.nightwingenterprises.com

                                  ------------------------------------------------

                                  • 14. Re: How do I count the number of a specific response?

                                    Ray,

                                     

                                    Understand everything you are saying.  Thank you for taking the time to explain.

                                     

                                    I'll check tomorrow to see if my work site has the advanced version.

                                     

                                    Most sincerely,

                                    Adam

                                    1 2 Previous Next