Moin: In reports I can display cumulated values of a field in the footer section by using CREATETOTALS. Is there a way to use the the current value of a section for own operations? Example: A report has two columns amount_1, amount_2 and percentage. The percentage in each row is generated by ROUND ( 100 * amount_1 / amount_2, 0.1 ) What do I have to do to get the apropreate percentage in the footer section? Regards Uwe
Hi Try the following logic create a countervalue and increment the values each time you trigger Createtotals. ie. the counter will containing no of rows effected. so it looks like … percentage = ROUND ( 100 * amount_1 / amount_2, 0.1 ); CREATETOTALS(percentage); intCounter = intCounter+1; In the footer section use controls source expression as percentage / intCounter Make sure reset the counter after footer section. If you want to appear the percentage in different sections like groups footer and report footer. Then counter will not help. Then try the following CREATETOTALS(amount_1 ); CREATETOTALS(amount_2 ); In the footer sections(even in group footer) use controls source expression as ROUND ( 100 * amount_1 / amount_2, 0.1 ); The above code is not tested , but I think it will help you. Regards Joseph Mathew
If you are using CREATETOTALS for amount_1 and amount_2 then these variables will have the correct totals when the footer section prints. Therefore the same source expression ROUND ( 100 * amount_1 / amount_2, 0.1 ) can be used to display the percent in the footer sections. Be careful about division by zero. You may want to define a function in the report to calculate and return the percent. This function could handle the possibility that the divsor may be zero. You can then use a call to this function as your source expression for the percent text box in both body and footer sections of your report.
The Calculation with the function above must be done in the trigger OnPreSection for the footer sections. You will find it in Section design and F9 when you marked the footer section. Per.Bay@navigera.com Product Manager www.navigera.com Edited by - Per Bay on 2001 Jun 01 08:35:53
Hmm, such a simple problem and three different answers? Follow Jack Reynolds as he’s entirely correct. The answer to your question is “nothing”. You have the correct values of amount_1 and amount_2 in every section. And do not forget to follow Jack’s advise about the function!!! ------- With best regards from Switzerland Marcus Fabian
In reference to Joseph Mathew reply, I would be concerned about summing a percentage field and then dividing by the number of lines. This is not good math and the results will be off. I don’t mean this as a slam at all. I simply learned this years ago in Avista while trying something similar. Bill Benefiel Manager of Information Systems Overhead Door Company email@example.com (317) 842-7444 ext 117