Percentage in report

1 Answer 31 Views
Report Designer (standalone)
Bradley
Top achievements
Rank 2
Iron
Iron
Iron
Bradley asked on 18 Feb 2025, 06:15 PM

This is likely trivial, but I don't even know what to search for.  I'm using "Telerik Reporting 2025".  I have a report that has a total (sum) at the bottom of a section.  I'd like to calculate the percentage of the total that the current line represents.  How do I put a field on a line that calculates the percentage for that line of the total of the grouping?

I'm likely explaining this very poorly, but feel free to ask for more details.

Bradley
Top achievements
Rank 2
Iron
Iron
Iron
commented on 18 Feb 2025, 11:22 PM

Yeah, I ended up doing it in SQL, which was fairly lame, but it works.

1 Answer, 1 is accepted

Sort by
1
Accepted
Krasimir
Top achievements
Rank 3
Iron
Iron
Iron
answered on 18 Feb 2025, 09:48 PM

Hello Bradley,

I couldn't find a way to deal with the aggregate calculations inside the details section. So, I'll be interested to see potential solutions that others would propose.

Are you using SQL DataSource? If yes, you could try to calculate the percentage within your SELECT statement. A sample based on the AdventureWorks DB would be:

SELECT 
    ProductID, 
    Name, 
    ProductNumber, 
    ListPrice,
SUM(ListPrice) OVER() as TOTAL,
    (ListPrice / SUM(ListPrice) OVER () * 100) AS ListPricePercentage
FROM Production.Product
WHERE ListPrice > 0;

Another "workaround" approach is to calculate the total in advance and send it as parameter to the report. Then, you can use the value in the details section. However, this approach would require that you make some preliminary calculations before rendering the report.

I've attached a sample screenshot to confirm that this is the case that you want to solve.

Regards,
Krasimir Baylov

Tags
Report Designer (standalone)
Asked by
Bradley
Top achievements
Rank 2
Iron
Iron
Iron
Answers by
Krasimir
Top achievements
Rank 3
Iron
Iron
Iron
Share this question
or