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

How to group and calculate percentage

4 Answers 111 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Paul
Top achievements
Rank 1
Paul asked on 31 Aug 2011, 10:38 AM
 I'm displaying a bar chart, the chart is grouped by date and a string value (Yes, No, NA). I need to show the percentage of each string value for each date, is this possible via the chart?

Can this be achieved by using a custom aggregate function? If so, could i possible see an example of how to create and implement a custom aggregate function.

4 Answers, 1 is accepted

Sort by
0
Ves
Telerik team
answered on 05 Sep 2011, 08:39 AM
Hello Paul,

Can you please show us a sample of the data and an example of the expected chart? Thanks.

Best regards,
Ves
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's DevProConnections Awards. We are competing in mind-blowing 20 categories and every vote counts! VOTE for Telerik NOW >>

0
Paul
Top achievements
Rank 1
answered on 16 Sep 2011, 02:17 PM
For example we will have an object like below:

Public Class ChartData
 
Public Result as string
Public HospitalName as string
Public WardName as string
Public AdmissionDate as date
 
End Class

And our data is something similar like below:
Result, Hospital Name, Ward Name, Admission Date
 
Yes, Hosp One, ACU, 01-01-2011
Yes, Hosp One, ACU, 01-01-2011
No, Hosp One, DRU, 01-01-2011
Yes, Hosp One, DRU, 01-01-2011
N/A, Hosp Two,  MUU, 02-01-2011
Yes, Hosp Two, MUU, 02-01-2011

We would like to group by admission date, result and hospital or ward and calculate the percentage of each result (Yes, No, N/A) for each hospital/ward for the admission date. We would like to display this as a bar chart with percentage as the Y Axis and Admission Date as the X Axis.
0
Ves
Telerik team
answered on 21 Sep 2011, 12:19 PM
Hi Paul,

Please, find attached a small example. It uses Grouping and DateTime grouping, along with StackedBar100 series, which is the most appropriate when you need to display contribution in percentage on multiple instances.

Kind regards,
Ves
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

0
Ves
Telerik team
answered on 21 Sep 2011, 12:39 PM
Hi Paul,

Just a quick follow-up. The previous example is in C#, you can find a VB version attached to this message.

Best regards,
Ves
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Tags
Chart
Asked by
Paul
Top achievements
Rank 1
Answers by
Ves
Telerik team
Paul
Top achievements
Rank 1
Share this question
or