This is a migrated thread and some comments may be shown as answers.

Average of calulated items

4 Answers 505 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Maxime
Top achievements
Rank 1
Maxime asked on 30 Nov 2007, 03:45 PM
Hi,

In a footer section, I want to obtain the average of a calculated textbox displayed in the detail section.

How I can do that ?

Regards,

4 Answers, 1 is accepted

Sort by
0
Svetoslav
Telerik team
answered on 03 Dec 2007, 10:23 AM
Hello Seb,

Let's assume that you have a text box which value is for ex. total sales:
   
    =Fields.Quantity * Fields.Price

To calculate the average of the above just add a text box to the report or the group footer section (page sections does not allow expressions with data fields!) and use an expression like this:

    =Avg(Fields.Quantity * Fields.Price)

All the best,
Svetoslav
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
0
Maxime
Top achievements
Rank 1
answered on 03 Dec 2007, 10:35 AM
Hi,

No,  it's not possible... The value of my textbox is calculated with a user function.

The only way I saw, is when the texbox is databound, to store the value and then to calculate manually the average.

It is not practical because the sums must be given to zero at each beginning of section.

And the value that I recover in the event databound can be formatted for display...

All ideas are welcome...

Regards,

0
Maxime
Top achievements
Rank 1
answered on 05 Dec 2007, 09:17 AM
Hi,

In the ItemDataBinding event can I retrieve the value tht will be set in my textbox.

The value is calculated bu user function.

Regards,
0
Rossen Hristov
Telerik team
answered on 06 Dec 2007, 12:32 PM
Hello Seb,

Summaries can be made on User Functions in the same way as you make them on data source fields. For example, if your summary function is:

    public static double CalculateOrderPrice(double unitPrice, int amount)
    {
        return (unitPrice * amount * 1.20); //add VAT :-)
    }

and your data field names are UnitPrice and Amount, you can set the following expression as the Value of a TextBox and it will calculate the Average on the results returned by the User Function:

=AVG(CalculateOrderPrice(UnitPrice, Amount))

I have prepared a little project containing a report that demonstrates the above. Examine it carefully and if you have any other questions, do not hesitate to contact us again.

Best wishes,
Ross
the Telerik team

Instantly find answers to your questions at the new Telerik Support Center
Tags
General Discussions
Asked by
Maxime
Top achievements
Rank 1
Answers by
Svetoslav
Telerik team
Maxime
Top achievements
Rank 1
Rossen Hristov
Telerik team
Share this question
or