SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


code to show top five entries in a pie chart


code to show top five entries in a pie chart

Author
Message
prb88
prb88
SSC Rookie
SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)SSC Rookie (35 reputation)

Group: General Forum Members
Points: 35 Visits: 50
Hello

I have a pie chart which displays many legends on a pie chart but i need to write sql code to show the top five entries/legends on the piechart. anybody provide a solution?
mikehunsaker
mikehunsaker
Valued Member
Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)Valued Member (50 reputation)

Group: General Forum Members
Points: 50 Visits: 180
Would this be a matter of adding TOP 5 to the SQL statement?

Something like


SELECT TOP 5 fieldname1, fieldname2 FROM tablename


peterzeke
peterzeke
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1900 Visits: 1766
Couple of thoughts for you to consider which might not give you the answer you desire, but certainly provides options:

1) Pie charts are not the best data visualization tool. Recommend using a horizontal bar graph instead. Here's a link from a data visualization expert, Stephen Few, on the topic: http://www.perceptualedge.com/articles/visual_business_intelligence/save_the_pies_for_dessert.pdf

2) If your data is aggregated in the SQL code, you could stamp row_number() in the SQL as a separate field (called "Rank") to identify your amounts. Then reference the Rank field to trigger the visibility of the category descriptions of the top 5: = iif(Fields!Rank.value<=5,False, True).

3) If you're using SSRS 2008 R2 or above, you could easily go with data bars within a table rather than a pie chart. Again, based on some sort of rank, only show the descriptions for the top 5:
http://msdn.microsoft.com/en-us/library/ee633676(v=sql.105).aspx

4) If you're still on SSRS 2005 (like me) you could embed a chart in a table. One column would display the category, another column would contain the bar chart. (Again, based on some sort of rank, only show the descriptions for the top 5.) See "SSW Better Rules to SQL Reporting Services": http://www.ssw.com.au/ssw/standards/Rules/RulesToBetterSQLReportingServices.aspx#maxminvalues

--Pete



Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search