Formatting numbers contained in SSRS charts

Hi,

I want my SSRS chart object to display the sum of one of my data fields in its title. The chart title text is defined as the following expression:
="Days Spent per Category ("
& CStr(Sum(Fields!days_spent.Value)) & " days total)"

Unfortunately this is displayed as:
"Days Spent per Category (66.500000 days total)"
instead of:
"Days Spent per Category (66.5 days total)"

I am already using the SQL ROUND function in the dataset query to ensure days_spent is always rounded to one decimal place, so this is just a presentation issue. Can someone please advise how this number can always be made to present with just one decimal place in my chart legend?

Many thanks.
irb56Asked:
Who is Participating?
 
planoczConnect With a Mentor Commented:
try this
="Days Spent per Category ("
& Sum(Format(Fields!days_spent.Value, "##.#")) & " days total)"
 
0
 
irb56Author Commented:
Thanks for such a quick response. This is very helpful. When I copied and pasted your code into my report, the chart title displayed "Error" but I quickly worked out that the Format function needs to wrap the Sum function rather than be nested within it. The following expression works perfectly.

="Days Spent per Category ("
& CStr(Format(Sum(Fields!days_spent.Value),"##.#")) & " days total)"

I wouldn't have got to this anything like as quickly without your solution, so much appreciated.
0
 
irb56Author Commented:
The solution is to use the Format function within the expression as per the expert solution but see my other comment for correction on structure of expression - Format needs to wrap the Sum function not be nested within it.
0
 
planoczCommented:
I did not have time to test the exact layout, but I knew you would get the idea :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.