10 Replies Latest reply: Sep 10, 2013 2:04 AM by Priyasagi RSS

    difference between place holders and formulas ?

    salute-Salem

      hi all , i want to know what can i do with place holders , i can not do with formulas ?

       

      when do i need to use place holders ??

       

      thanks in advance

        • 1. Re: difference between place holders and formulas ?
          MLBrown

          I will use a formula when I am performing one distinct action.  For example, if a user passed in a parameter of 101 and I wanted the header of my report to be "CLASS NUMBER 101" then I would use a formula and return the title of the report.

           

          I would use place holders if I needed to compute several different things in a formula.  For example, if a user passed in a parameter of 101 for a class and based on that number I needed to figure out the number of people in that class, the average test scores for that class, then number of people that were absent at any particular time for that class, etc... Then I could create one formula and save those different values into place holders instead of creating one formula for each or those things I wanted to figure out.

           

          That's what I use them for - hope it helps.

           

          -mike

          • 2. Re: difference between place holders and formulas ?
            salute-Salem

            the first example of yours :-

            > I will use a formula when I am performing one distinct action.  For example, if a user passed in a parameter of 101 and I wanted the header of my report to be "CLASS NUMBER 101" then I would use a formula and return the title of the report.

            can not i do this with just a formula ??

             

            the second example is clear , but should i create 3 fields in the layout to get their sources from the place holder columns ?

            • 3. Re: difference between place holders and formulas ?
              MLBrown

              Exactly.  I would create three place holders and they would have three corresponding fields in the layout for the second example.

              • 4. Re: difference between place holders and formulas ?
                salute-Salem

                you did not answer my question about your first example ,

                can not i do this with just a formula ??

                • 5. Re: difference between place holders and formulas ?
                  MLBrown

                  You can only return one value with a formula so for the first example - yes, you could just use a formula because you are only building the title.

                   

                  For the second example, you could use the one formula, three placeholder method or you could use three separate formulas.

                   

                  I hope that makes sense.

                  • 6. Re: difference between place holders and formulas ?
                    salute-Salem

                    can not i assign values to formula columns through a forumla column , like you did in the place holder columns example

                     

                    i mean , i create a basic formula column to assign values to three other columns

                    like

                     

                    cf1 := anything

                    cf2 := another thing

                    cf3 := another ??

                     

                    is this the idea ?

                     

                    2- by the way , how to change the title of the report by code ?

                    • 7. Re: difference between place holders and formulas ?
                      MLBrown

                      For a formula, you are only returning one value.

                      So... if a user sent in a parameter of :p_class_number = 101 and I wanted to build a title for my report then I could create a formula named :CF_Report_Title and set it to a Character Datatype with a width of 20 for example.  I could then go into the formula and create the following:

                       

                      function CF_Report_TitleFormula return Char is

                      begin

                         return 'Class Number ' || :p_class_number;

                      end;

                       

                      In the layout I would then create a Field named something like F_Report_Title and in the property pallete I would set the source to by formula :CF_Report_Title

                       

                      For the second example, I could create three more formula's just like I did above to compute the number of people in that class, the average test scores for that class, and the number of people that were absent at any particular time for that class, but instead of having all of those formula's I would personally create three placeholder columns and name them something like:

                       

                      :CP_class_count

                      :CP_avg_scores

                      :CP_absent_count

                       

                      In the property palette I would probably leave all of these as NUMBER(10) because for this example I am returning numbers.  I would then create a formula named :CF_class_info and set the Datatype to NUMBER(1).  In the actual formula, I would create a function that looked something like this:

                       

                      function CF_Class_InfoFormula return Number is

                      begin

                        --

                        -- Compute the class count

                        --

                        select count (*)

                            into :CP_class_count

                            from class_detail

                          where class_number = :p_class_number;

                              and ...;

                       

                        --

                        -- Compute the Average Score

                        --

                        select average(class_score)

                            into :CP_class_count

                            from class_scores

                          where class_number = :p_class_number;

                              and ...;

                       

                        --

                        -- Compute the Abscenses

                        --

                        select average(class_score)

                            into :CP_class_count

                            from class_abscence

                          where class_number = :p_class_number;

                              and ...;

                       

                        --

                        -- Finished with this formula

                        --

                         return 1;

                      end;

                       

                      At this point, I have run the formula one time, but was able to populate three placeholders.  I can then create fields in the layout and reference these placeholders instead of having to create three separate formulas.  It works either way, it is just whatever you prefer to do because they would both work.

                      • 8. Re: difference between place holders and formulas ?
                        salute-Salem

                        you did your best , and i got everything you wrote clearly ,

                        but your words mean that there is no difference between using any of them ,

                         

                        is that mean that there is nothing i can do with place holders which i can not do with formulas , and vice versa

                         

                        and about your example , i think using three formulas with 3 fields is easier than using one formula with 3 place holders which means 4 fields not three !!??

                        thanks a lot

                        • 9. Re: difference between place holders and formulas ?
                          MLBrown

                          I would say that is true.  It is just a matter of preference.

                          • 10. Re: difference between place holders and formulas ?
                            Priyasagi

                            Hi,

                             

                            Place holder column is an empty container at design time, which is used to hold some value in run time.  Like a global variable we can call anywhere in the report.

                            We can use the place holders even in report triggers also.  Concluding point of view, we can use place holders inside and outside of the data group.

                            But formula column is entirely different, to calculate some information dynamically we use formula columns.  We can not store & call formula column anywhere in the report.

                             

                            I hope my answer will satisfy you.