# How to sum group-footer values?

1. ##### Simon
76 posts
Member since:
Sep 2018

Posted 06 Aug 2019 Link to this post

Hello,

I have a report to show vehicle datas.

For each group here the vehicle, e.g. PCH W 100,  I calculate the difference with the formula

`= (MAX(Fields.Mileage) - MIN(Fields.Mileage)) + " km"`

(See black arrows in the attached screenshot!)

The result should be summed up and displayed in the bottom line.

But I have no idea how to make it.

This throw an exeption:

`= Sum((MAX(Fields.Mileage) - MIN(Fields.Mileage)))`

Best Regards.

2. ##### Eric R | Technical Support Engineer
247 posts

Posted 08 Aug 2019 Link to this post

Hi Simon,

This appears to be the SUM in the total formula. Since the data is grouped on the Fahrzeug row it creates a group Scope within the Crosstab and the calculations values would use the same formula.

This means that the group total value isn't grouped and would calculate the value containing the whole data set.  In contrast, the subtotal group calculates the value over each group.

For the total, the formula would be like the following.

`[= MAX(Fields.Mileage) - MIN(Fields.Mileage)]`

Alternatively, this could be quickly achieved using the Crosstab Wizard. Let me provide a visual guide below.

Step 1: Select the data source.

Step 2: Arrange the Fields

Step 3: Select the Subtotal/Total Layout

For reference, I have also attached a sample report.

Please let me know if you need any additional information. Thank you.

Regards,

Eric R | Technical Support Engineer
Progress Telerik

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
3. ##### Simon
76 posts
Member since:
Sep 2018

Posted 09 Aug 2019 Link to this post

Hello Eric R,

The Subtotals are correct calculated, the difference between maxvalue and minvalue, but the total not.

The total should be the sum of all Subtotals and the result must be 11636.

In my case, how I try to demonstrate in the above screenshot Vehicle-Report.jpg, I want to sum up all the values in the groupfooter lines.

So the result would be 17104.

Is there an easy way to sum up all the groupfooter-values (or whatever you call it:Subtotals) ?

Best Regard

Simon

4. ##### Eric R | Technical Support Engineer
247 posts

Posted 12 Aug 2019 Link to this post

Hi Simon,

In this case, the User Aggregate Functions will achieve the desired result. I have attached a sample that accomplishes this and will provide a brief explanation with resources below. Note that the sample is provided in the Visual Studio Report Designer and can also be accomplished by Extending the Stand Alone Report Designer

Explanation
User aggregate functions allow the use of custom logic in aggregates. After implementing the custom logic, the value is either calculated as a SUM or a DIFFERENCE based on the rowKind which is passed into the function as SUBTOTAL or TOTAL. Below is the formula in the Subtotal and Total value properties.

Subtotal:

`= 'Subtotal: ' + CalcDifference(Fields.Source, Fields.Mileage, 'SUBTOTAL')`

Total:

`=CalcDifference(Fields.Source, Fields.Mileage, 'TOTAL')`

Report Preview:

Resources
Implementing Custom Aggregates KB Article
Calculations Based on Another Field KB Article

Please let me know if you need any additional information. Thank you for using Telerik Reporting.

Regards,

Eric R | Technical Support Engineer
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
5. ##### Simon
76 posts
Member since:
Sep 2018

Posted 13 Aug 2019 Link to this post

Thank you very much.

But I have an error message when I try to run your given project.

Best regards

Simon

6. ##### Eric R | Technical Support Engineer
247 posts

Posted 13 Aug 2019 Link to this post

Hi Simon,

This will require Configuring the Telerik Nuget Feed for Visual Studio. Once this is configured the NuGet packages will restore properly.

Please let me know if you need any additional information. Thank you.

Regards,

Eric R | Technical Support Engineer
Progress Telerik
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
7. ##### Simon
76 posts
Member since:
Sep 2018

Posted 14 Aug 2019 Link to this post

Hello,

I still have this error message, but it doesn't matter anymore.

Because I have acces to your source code and MileageReport.cs .

I have copied this and it works fine.

That helps me a lot, thank you!

Although it seems a little complicated.

Best Regards

Simon