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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

averaging strings 1

Status
Not open for further replies.

gav12345

Programmer
Dec 4, 2003
198
GB
Hi,

I'm trying to average some data stored as a string. I thought the way to do this would be to use the following:

average(tonumber({GET_CONTRIBUTION_MEASUREMENT.DATA_VALUE}))

...but this gives me the error message 'A field is required here'.

Can anyone enlighten me? Many thanks.

Gavin
 
When a complex command fails, the best step is to split it and see which bits do work. Try tonumber({GET_CONTRIBUTION_MEASUREMENT.DATA_VALUE}) on its own and see if that works. Then try {GET_CONTRIBUTION_MEASUREMENT.DATA_VALUE} on its own - could you have the name wrong. Do cut-and-paste and commend out the version you aren't using. (// turns a command into a comment)

[yinyang] Madawc Williams (East Anglia, UK) [yinyang]
 
Sorry, bad form. - I'm using CR 10 against a stored procedure from Oracle 9i.

Gavin
 
Thanks Madawc. - Yes, I've actually done that which I should have mentioned. Its the 'average' function which fails. I've tried 'tonumber' and 'cdbl' functions on the field which both work OK. Its when I try to use the 'Average' function on the result that I have problems.

I've tried putting the result of the 'tonumber' function into a variable and using the 'average' function on that, but I get the same error message. I.e., Its the average function which is failing for some reason.

Any ideas?

Thanks, Gavin
 
Do this in two separate formulas:

//{@makenumber}:
tonumber({GET_CONTRIBUTION_MEASUREMENT.DATA_VALUE})

//{@average}:
average({@makenumber})

-LB

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top