3 Replies Latest reply on Apr 5, 2016 1:25 AM by tkemmere

    Using variables in a sub-summary report


      ...I'm wondering, is it somehow posible to use variables in a sub-summary report? I guess not, because I need the variable to be different for every row.




      So I have this sub-summary report, (say a contact person list, grouped per province) and for some persons a field is left blank, and for others there is a value, for example the phone number. It is mostly known, but sometimes left blank. Suppose there is no phone number, then I also wouldn't like "Phone: " in my report. So thought I'd create a variable $Phone with

      If ( IsEmpty (Contactpersons::Phonenumber); "" ; "Phone: " & Contactpersons::Phonenumber)

      And then putting <<$Phone>> into the row in the sub-summary row. But the problem is that that variable is only loaded once, not for every corresponding row, so it displays all the same.


      Unfortunately I can't solve this with "Hide object when" because it gets more complicated: Like depending on the content of various fields, different texts have to be displayed.


      How would you go about it? It there a solution you know? Thanks for your answer in advance.




        • 1. Re: Using variables in a sub-summary report

          The "old school" method is to use a calculation field.


          The newer method would be to hide the label using Hide Object in the Inspector. Yes, you can do this with multiple objects if you use all the objects and set criteria for each. Depending on exactly how complex, the calculation field might be better.

          • 2. Re: Using variables in a sub-summary report

            The “even newer school” would maybe use a single-segment button bar and put the calculation into the label calculation, or employ a placeholder calculation – both of which are (mis-)used as non-official "layout calculations", until the real thing comes along …


            PS: To answer your original question: Until the advent of these features, sometimes people used the calculation engine of some layout object attribute (e.g. Conditional Formatting) to define a $var that was record-dependent. Alas, that was a) a bit unreliable in refresh, and b) the calculation was hidden away within an object that you delete inadvertently …


            PPS: If you use Case(), you don't have to define an empty default result:


            Case (

              not IsEmpty ( Contactpersons::Phonenumber ) ;

              "Phone: " & Contactpersons::Phonenumber



            or even:


            Let (

              thePhone = Contactpersons::Phonenumber ;

              Case (

                not IsEmpty ( thePhone ) ;

                "Phone: " & thePhone




            but for such a simple calculation, this is admittedly more a question of personal taste.

            • 3. Re: Using variables in a sub-summary report

              Again, two answers that are equaly correct! :-) Thanks guys.


              As you can see I'm still learning these obvious things. I guess with time such aproaches wil occur to me automatically so I won't have to ask over here.


              In the case of the database I'm working on, creating Calculation fields with the Case() function in them will work best.


              Thanks and have a wondrous day!