Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing decimal places from X Axis of chart in version 10 1

Status
Not open for further replies.

pgevaux

Vendor
Mar 4, 2006
14
GB
In version 10 of CR it isn't easy to format the x-axis of a chart. I don't know why. I think in XI you can with the chart expert. How I got around this was to create a formula and base the x-axis of the chart off it. This is the formula I created:

//START OF FORMULA
// This formula basically strips off the '.00' (two decimal places) from the number in the database, so that it doesn't appear on the xaxis of a chart.
Shared stringVar score:= totext({table.field}); //This creates a shared string variable called 'score', and assigns the value of the field to it.
if score [3] = "." then left(score, 2) else //This caters for a two-digit number (e.g. 22.00)
if score [2] = "." then left(score, 1) else //This caters for a one-digit number (e.g. 2.00)
left(score, 3) //This caters for a three-digit number (e.g. 222.00)
//END OF FORMULA

So if the input is '22.00', the output becomes '22'.

There is probably a more efficient way of coding this, but it worked for me. I hope it can help someone else.

Regards

Phil Gevaux
 
After some testing I realise this doesn't work. Sorry for the previous thread. You cannot use shared variables at chart processing level apparently. This formula below does work. I don't know why I was trying to use a variable when it wasn't needed.

// This formula basically strips off the '.00' (two decimal places) from the number in the database, so that it doesn't appear on the xaxis of a chart.
if totext({table.field}) [3] = "." then left(totext({({table.field}) }), 2) else //This caters for a two-digit number (e.g. 22.00)
if totext({({table.field}) }) [2] = "." then left(totext({({table.field}) }), 1) else //This caters for a one-digit number (e.g. 2.00)
left(totext({({table.field}) }), 3) //This caters for a three-digit number (e.g. 222.00)

Regards

Phil
 
I think you could simplify your formula down to just this:

totext({table.field,0)

The totext function has optional arguments that allow you to control the number of decimals that are displayed once converted, as well as what character to use as the thousandths seperator. Look up the function in CR help to get more info.

~Brian
 
I knew there must be an easier way. Thanks for sharing it. I'm still a novice at formulas, and this forum is my lifeline.

Regards

Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top