11 Replies Latest reply on Aug 10, 2017 6:28 AM by beverly

    Functions Count(),List(),etc. with only one variable/constant - why no results?

    eworbit

      I feel like a noob for asking this.  Why doesn't List("justme") echo anything?

       

      In data viewer, I get this error what trying to evaluate it:

       

      "In the function Average, Count, Extend, GetRepetition, Max, Min, NPV, StDev, Sum, GetSummary or GetNthRecord, an expression was found where a field alone is needed."

       

      Yeah, so what about List()??....

       

      Some functions in FM can take a variables or constants even though the documentation heavily favors the word "field".

       

      http://www.filemaker.com/help/12/fmp/html/func_ref1.31.4.html

       

      List(field{;field...})

      should be

      List(field|variable{;field|variable...})

       

      List("justme") - not valid

      List("justme";"metoo") - valid

      Count("justme")  - not valid

      Count("justme";"metoo") - valid "2"

      Count("justme";"") - valid "1"

      Min("5") - not valid

      Min("5";"6") - valid "5"

      Min("5";"") - valid "5"

       

      Is this just very old legacy stuff FM doesn't want to fix?

       

      -Eric

        • 1. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
          coherentkris

          I would say its insufficient documentation thats probably not "low hanging fruit" for the bug/issue fix team.

          I'm perfectly ok with documentation that is lacking if they allocate those resources to improving the quality of any given release of the product.

          • 2. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
            TomHays

            eworbit wrote:

             

            List("justme") - not valid

            List("justme";"metoo") - valid

             

            I agree that the documentation on this is lacking, but it does have two bullet points under Description that describe the two independent behaviors of this function.  (I interpret the difference as a form of polymorphism.)

             

            It is programmed to have a different behavior when you provide one argument versus multiple arguments.  Its job is to assemble multiple items into a list.  How it obtains the multiple items differs with single vs. multiple argument invocations.

             

            List( _one_argument_) : interpret the single argument as a multi-valued entity.  The multiple values could come from repetitions of this field or multiple values of this related field.

             

            List( _multiple_; _arguments_; _provided_; _explicitly_): interpret the arguments simply as provided and assemble into a list.  No attempt is made to discover hidden depth in each argument.  A single repetition or a single related value is extracted for each argument.

             

            -Tom

            • 3. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
              steve.thoms

              It should be noted that if you supply a single parameter, and it is a field, the field value is returned. This error seems to occur only where an expression or variable is used.

              e.g.

              List ( Password::Client ) returns "Hertz"

              List ( "test" ) returns blank in the Data Viewer and "?" in a calculation

              List ( "test" ; "test2" ) returns "test¶Test2"

               

              So this seems a bug to me.

              • 4. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                TomHays

                steve.thoms wrote:

                 

                It should be noted that if you supply a single parameter, and it is a field, the field value is returned. This error seems to occur only where an expression or variable is used.

                e.g.

                List ( Password::Client ) returns "Hertz"

                List ( "test" ) returns blank in the Data Viewer and "?" in a calculation

                List ( "test" ; "test2" ) returns "test¶Test2"

                 

                So this seems a bug to me.

                 

                 

                The single-argument behavior of List() is to assemble all values of the field provided.

                This is either all repetitions or all related values.

                List( Password::Client ) returns "Hertz" because...

                has one repetition or one related value which is returned

                or

                it has multiple repetitions and all but one are blank

                or

                it has multiple related values and all but one are blank.

                 

                A text constant cannot be evaluated in the context of having repetitions or additional related values so it is an invalid argument for that mode of List().

                 

                You can think of List() as two separate functions behind the scenes.

                List_SingleArgument()

                List_MultipleArgument()

                since it has different programmed behavior for those different ways of invoking it.

                 

                It may well be that users would be less confused if FileMaker made two different named functions for the different behaviors.  Perhaps some developers were arguing for that before the final decision was implemented.

                 

                When you use List(one_argument), that one_argument must be a field (or a $variable which is able to have repetitions).

                 

                -Tom

                1 of 1 people found this helpful
                • 5. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                  TomHays

                  Can you clarify why you would want to type in any of the following?

                   

                  List("justme")

                  Count("justme")

                  Min("5")

                   

                  In what calculation context would this be useful?

                   

                  -Tom

                  • 6. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                    ch0c0halic

                    Perhaps a quick look at the Function definition will help.

                     

                    https://fmhelp.filemaker.com/help/16/fmp/en/#page/FMP_Help%2Flist.html <https://fmhelp.filemaker.com/help/16/fmp/en/#page/FMP_Help/list.html>

                     

                    List

                    Purpose

                    Returns a concatenated list of non-blank values for a field or fields.

                    Format

                    List(field{;field...})

                     

                    Parameters

                    field - any related field, repeating field, or set of non-repeating fields; an expression that returns a field, repeating field, or set of non-repeating fields, or a variable.

                     

                    Note that the Function is defined to only accept Fields or a variable, not text.

                     

                     

                    Looking at the examples if a variable is used it also uses a field.

                    Example 5

                    List ($f1; Field2) returns:

                    •orange

                    •black

                     

                    I'm not sure we can draw any hard conclusions from this but I'd rather work on real world requirements than fabrications that will, in all likelihood, never come up.

                     

                    BTW, there are other functions that behave like this. The use of text or a variable alone is often only a mental excursive and does not have a real world application. FMI Development has often responded with "Performs as expected."

                    • 7. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                      beverly

                      There was a recent thread here (or Product Issues or Ideas) about this. I cannot seem to find it now.

                       

                      Perhaps a thought trigger off this?

                       

                      Or maybe elsewhere...

                      I try to be explicit. I test if a function requires "more than one value" (parameter of otherwise), then I use other functions or methods to 'get' (or 'set') what I need.

                      Beverly

                      • 8. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                        eworbit

                        ch0c0halic said:

                        "Note that the Function is defined to only accept Fields or a variable, not text."

                         

                        In about ALL the languages I know, a constant/string can be passed in place of a variable.  PHP calls this is a "mixed" parameter.  Understand that FM is gladly accepting text - possibly to the chagrin of hard core FM developers.

                         

                        If variables/constants were so taboo then the FM needs to error out on people doing this:

                        Min(5,6);

                        because the function "requires" a "field"

                        Min(field{;field...})

                         

                        Now, of course, that would be nonsense.

                         

                        PHP manual states that at least two parameters are required in min/max function.  So FM manual could use some updating in this regard.

                         

                        As far as List is concerned, it too will gladly accept text constants with no error.  But there is some artificial requirement that that there is no such thing as a 1 item list unless you tack on a ;""   ie. List("justme";"");

                         

                        Why do I need the ;""  ?

                         

                        LET ([

                        $var="field¶missing"

                        ];

                        List($var;"")

                        )

                        • 9. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                          ch0c0halic

                          All I'm saying is in any product you have to take into account what the manufacturer says in their documentation. Just because the list() function allows text strings instead of 'Fields' does not mean the product developers support it.

                           

                          If you want to test a Function I suggested using real world scenarios with the parameters as defined in the documentation. I then noted that when I've seen other similar posts the answer has been, "Works as intended, if not as desired." and nothing is changed because nothing is 'wrong'.

                           

                          FMI resources are constrained too. I suggest you submit it as a suggestion and if enough people support it maybe it will get some attention.

                           

                          I don't think the PHP manual has anything to do with FMP.

                          • 10. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                            user19752

                            Your look was too "quick",

                            https://fmhelp.filemaker.com/help/16/fmp/en/#page/FMP_Help%2Faggregate-functions.html%23

                            says clearly

                            The parameter values can include a numeric constant (for example, 10) or any valid expression.

                            So I think this is a good example of bad documentation of FM... In such case, syntax definition in each function should be like

                            Average(expression{;expression...})

                            since field reference or constant is a form of expression.

                             

                            Using fields in aggregate functions is the most case so may be helpful for "beginners" (he'd say "what is expression?") , but not for "programmer".

                            2 of 2 people found this helpful
                            • 11. Re: Functions Count(),List(),etc. with only one variable/constant - why no results?
                              beverly

                              Yes take into account the documentation! Sometimes it's "not quite" sufficient:

                              Use Variables in Aggregate Functions (not just fields)

                              And it the 'feature' works but is NOT intended, I think the documentation should say that as well.

                               

                              The php.net "manual" suggestion has come up many time because of the ability to add content in the form of comments. If there were a place to at least link to the FM Help documentation with comments, that would benefit all. Perhaps it needs to be "moderated" (to confirm correct and non-harmful behavior), but it's just an idea!

                              Beverly