2 Replies Latest reply on Sep 13, 2012 9:29 AM by MarcMcCall

    Counting the number of time a specific word is in a field

    MarcMcCall

      Title

      Counting the number of time a specific word is in a field

      Post

            

           Hey guys,
            
           I have a field that contains text as below.  I want to make a calculation field that counts the number of times the word "Evolution" appears in the field.  the field containg trhe text is  wsdl_load_results.  The field contains the functions loaded by a plugin fror my websites API functions.  I want to count the functions so I can add a subscript to my start up that looks to see if any new functions get added by the web site developers and lets me know at start up.  
            
           Evolution_MarkOrderLine( MarkOrderLine_ServerID; MarkOrderLine_TokenKey; MarkOrderLine_Password; MarkOrderLine_SalesID; MarkOrderLine_EntityID )
           Evolution_ProductDetailsEVO( ProductDetailsEVO_ServerID; ProductDetailsEVO_TokenKey; ProductDetailsEVO_Password; ProductDetailsEVO_ProductID )
           Evolution_ProductDetailsSKU( ProductDetailsSKU_ServerID; ProductDetailsSKU_TokenKey; ProductDetailsSKU_Password; ProductDetailsSKU_SKU )
            
           Thanks in advance.
           Marc

        • 1. Re: Counting the number of time a specific word is in a field
          philmodjunk

               A crude "first cut" at this is to use the patterncount function:

               Patterncount ( wsdl_load_results ; "Evolution" )

               But this will also count words that contain this text such as "evolutionary"--so it may not be precise enough for your needs.

               A more sophisticated approach might be something like this:

               Let ( Tlist = Substitute ( wsd_load_results ; ["_" ; ¶ ] ; [" " ; ¶ ] ) ; //you may need to include more "word separators" than "_" and " "
                       PatternCount ( ¶ & Tlist & ¶ ; ¶ & "Evolution" & ¶ )
                     )

               Whether you need such additional sophistication or not is something that is up to you to determine.

          • 2. Re: Counting the number of time a specific word is in a field
            MarcMcCall

                 I don't know how I forgot PatternCount!!!

                 This works perfect, as the only word it will ever contain is Evolution, no other forms of the word.