[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


Need help with Data Bar chart

Posted on 2012-04-04
Medium Priority
Last Modified: 2012-04-09
I've created a report that lists projects, their budgets, amount already spent and amount remaining in the budget.  What I'd like to do is have a small data bar chart in the last column that visually displays the amount of the budget spent for each client/project as a percentage.

I attached a picture of what I had in mind.  At a glance my boss would be able to look down the page at a list of projects and see which ones were 50% spent, 90% spent or overspent.  I'm just not sure how to customize a chart to do this.  Plus a lot of my figures are calculated so perhaps I should create a seperate dataset for the chart?  I thought of using a pie chart but I think the data bar chart is a better solution.

Any ideas or input please share!    If anyone with report/chart experience has a suggestion of how to display the desired graphical data I'm all ears!
Question by:HSI_guelph
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
LVL 22

Assisted Solution

by:Nico Bontenbal
Nico Bontenbal earned 2000 total points
ID: 37809633
See this article: http://technet.microsoft.com/en-us/library/dd239361.aspx
You'll need the "stacked bar".  Not sure what you want to do with the overspent. I think you should have a green bar up to 100% and then a red bar attached to it with the overspent (10% for example). You might not need an separate dataset. You probably can do all the calculations in the report.
The data labels are probably the most tricky part because you want to display the total budget also. I need to experiment somewhat to give you the right answer. I can make an example for you but than I need to know what version of SQL server you are using. And could you upload the report (.rdl) here so I can use that as a starting point.

Author Comment

ID: 37811789
I'm using a virtual machine running MS SQL Server 2008 R2 to access a virtual MS SQL Server 2005 database (does that even matter? that its a different version then what I'm developing on?).

Here is a copy of the .rdl.  I'm not sure it matters how much the project is over as much as what is left in the budget (if they are over they are over but if they are way under just before the end of contract they need to allocate the funds since many projects are smaller ones of a master project).

It would be cool if I could get the bar to be green when they are under 50%, yellow if they are 50-75%, orange 75%-90% and red when they are either 100% or 90%-100% (numbers are just examples).  I read that there are stop lights I can implement into the report which would be ok to use too.  I would like something that is clear and simple to draw the eye to key areas that might be of concern/interest.  Any graphical tool would suffice but a bar would show how all projects are doing budgetwise.  Also the number of clients on a page may vary and I don't want a big graph on the page but a small indicator per row.

Author Comment

ID: 37812407
I got it working!  I changed it to a stacked bar, like you suggested, and then went into the series properties fill tab and entered the expression for color:
=Switch((Sum(Fields!Expenses.Value) + Sum(fields!Labour.Value)) > fields!Budget.Value, "Red",
(Sum(Fields!Expenses.Value) + Sum(fields!Labour.Value)) > fields!Budget.Value*.85, "Orange",
(Sum(Fields!Expenses.Value) + Sum(fields!Labour.Value)) < fields!Budget.Value*.85, "Green")

Its working great but I am running into some instances where I'm dividing by 0 and getting an #Error.  If that happens I'd like the fill color to be the same as the background, white, but I am having no luck adding a test for error into my above expression.

Any ideas please?
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Author Comment

ID: 37812547
Also I am getting a warning
Warning      1      [rsRuntimeErrorInExpression] The Color expression for the chart ‘DataBar2’ contains an error: Input string was not in a correct format.      C:\Users\hsiadmin.HUMANSYSTEMS\Documents\Visual Studio 2008\Projects\Report Development\Report Development\BudgetExample.rdl      0      0      
Do I need to correct this?  Will it impact running the report?
LVL 22

Accepted Solution

Nico Bontenbal earned 2000 total points
ID: 37813082
Well done! I was just starting the example but it looks like you are ahead of me. You can get around the division by zero by using an if statement. But be careful, both parts of the iif are evaluated, so you might still get an error. So if something like:

Open in new window

return the error. You need to change it to:
=iif(Fields!Budget.Value = 0, 0, Sum(Fields!Labour.Value)/iif(Fields!Budget.Value=0,1,Fields!Budget.Value))

Open in new window

And you can use the Fields!Budget.Value = 0 criterium for your color also and make sure it returns white. Or use it for the Hidden property of your Chart so the chart doesn't display at all.

You expression for the color returns null if none of the expressions are true. I think that is what causing the error. Try adding
True, "White"

Open in new window

to the switch statement to make sure it always return a valid color. If that doesn't help add an extra column to your table with the expression you use for the color. That way you can see what the expression returns and makes it easier to debug.

Author Closing Comment

ID: 37813165
Thank you very much for the help!  Sometimes its more helpful to get advice on how or what you want to display rather than the code since the code is pretty rigid, its the mind of the coder that creative and flexible.
LVL 22

Expert Comment

by:Nico Bontenbal
ID: 37815257
You're welcome. When I read your post of  2012-04-05 at 16:12:19 I was afraid we still had a long way to go. So my compliments to you for getting this working with only a few hints.

Author Comment

ID: 37823528
Thank you :)

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Written by Valentino Vranken. Introduction: In a previous article (http://www.experts-exchange.com/articles/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Reporting-On-Data-From-Stored-Procedures-part-1.html) I announced that I would writ…
A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
Suggested Courses

650 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question