4 Replies Latest reply on Jun 30, 2017 8:13 AM by erolst

    Plural Form of Sort List Key in Sub-Summary Part

    bee13

      I want the Sort List Key merge field that's placed in a layout's sub-summary part to reflect the plural form (essentially an "s" on the trailing end) when the count for each sort break is not equal to 1 (≠ 1).

       

      I have tried using a Summary Field that counts the number of record IDs as well as various Case logic structures in the Sort List Key calc field, all to no avail.  The problem is that none of these approaches 'sees' the Count from the perspective of being inside a sorted sub-summary layout part; they look at the entire found set.

       

      Is there a simple way to determine and reflect the plural form of the Sort List Key in a sorted/break state?

       

      Thanks!

        • 1. Re: Plural Form of Sort List Key in Sub-Summary Part
          philmodjunk

          "Is there a simple way to determine and reflect the plural form of the Sort List Key in a sorted/break state?"

           

          Use the getSummary function

          • 2. Re: Plural Form of Sort List Key in Sub-Summary Part
            bee13

            Hi Phil. Thanks for the quick reply ( it's your way, I know!).

             

            I see how the GetSummary function is well-suited for my particular need but I have spent hours attempting to implement it with results varying from a recursive loop to just plain not working.

             

            DESIRED RESULT in Browse Mode (list format)

            After sorting the found set, records with like Real Property categories are grouped.  A sub-summary part is situated before each sorted grouping and reflects the group's Real Property category, expressed in singular or plural form, as the case may be.

             

            Here's my set-up:

             

            LAYOUT

            List format with a sub-summary part containing a Merge Field for c_Sort List Key (the break field?)

             

            FIELDS

            Sort Selection  //text,global,auto-enter calc,replace existing value displayed in pop-up menu form with value list related to Real Property.  Expression: If ( IsEmpty ( Self ) ; "Category" ; Self )

             

            c_Sort List Key  //calc field with logic to determine 1) type of real property, and 2) if instances of that property category should be displayed as singular or plural.  (See expression below)

             

            c_breakSum  //calc field with the expression: GetSummary ( s_Count ; Sort Selection )

             

            s_Count  //summary field which counts record IDs for the found set

             

            LOGIC CALCULATION for FIELD  c_Sort List Key

             

            Let ( [

             

              $sortSel = GetField ( Sort Selection ) ; // from a pop-up menu list of values

              $breakSum = c_BreakSum ;  // field with GetSummary function

              $sortSelPlural = If ( $breakSum = 1 ; $sortSel ; $sortSel & "s" ) ] ;   // adds an "s" for plural cases

             

            Case (

             

              $sortSel = "Mobile Home Park" and $breakSum = 1 ; $sortSel ;  //Mobile Home Park

              $sortSel = "Mobile Home Park" and $breakSum ≠ 1 ; $sortSelPlural ;  //Mobile Home Parks

              $sortSel = "Mobile Home" and $breakSum = 1 ; $sortSel ;

              $sortSel = "Mobile Home" and $breakSum ≠ 1 ; $sortSelPlural ;

              $sortSel = "Warehouse" and $breakSum = 1 ; $sortSel ;

              $sortSel = "Warehouse" and $breakSum ≠ 1 ; $sortSelPlural ;

              $sortSel = "RV Park" and $breakSum = 1 ; $sortSel ;

              $sortSel = "RV Park" and $breakSum ≠ 1 ; $sortSelPlural ;

              $sortSel

             

            )

            )

             

            1. Is the Sort Selection field the break field (the one in the sub-summary part) or is it c_Sort List Key?

            2. When I use c_Sort List Key as the break field in the GetSummary function the solution goes into infinite recursion.

             

            I haven't used this function before so I am kind of lost on this one!

             

            Thanks Again.

            • 3. Re: Plural Form of Sort List Key in Sub-Summary Part
              philmodjunk

              Which field do you sort on to get the sub summary part to appear?

               

              That's the field to specify as the break field in the getsummary function.

               

              This line looks incorrect:

               

                $sortSel = GetField ( Sort Selection ) ;

               

              Seems like it should be:

               

                $sortSel = Sort Selection  ;

              • 4. Re: Plural Form of Sort List Key in Sub-Summary Part
                erolst

                PhilModJunk already pointed out that the usage of GetField() isn't correct here.

                 

                As to your calculation: you can simplify it like this if every plural form can be formed by appending an "s":

                 

                Sort Selection & If ( BreakSum 1 ; "s" )

                 

                There is no need to use Let() if you do not have complex expressions or reference the same field multiple times. (But if you do use Let(), there is no need to create prefixed variables, i.e. $variable.)

                 

                If you want to limit the conditional plural form to specific words, try

                 

                Let ( [

                  pluralWords = List ( "Mobile Home Park" ; "Mobile Home" ; Warehouse" ; "RV Park" ) ;

                  selection = Sort Selection ;

                  ] ;

                  selection &

                  If (

                    not IsEmpty ( FilterValues ( selection ; pluralWords ) ) and BreakSum 1 ;

                    "s"

                  )

                )