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

hyperion format values

Status
Not open for further replies.

carranz

Technical User
Nov 17, 2006
40
US
Im using hyperion reporting software. I have a field in my results. this field holds number values. some of the values have decimals and some don't. I would like to have the field to hold 6 places and remove the decimals and have zeros at the end.

Does anyone know how to do this?
 
example.
value 123.1
result 123100

but the values are different
 
this works great I have another problem.
I have a value with a letter in it

example
630G
I would like the result to be
63000

any help would be appreciated
 
Hi

Ok, but you forgot to explain the rule.

Anyway, the [tt]parseInt()[/tt] function will extract the numeric part of the string up to the first invalid character. But we know nothing about the further formatting and apparently the decimal place requirement also changed.
Code:
result=[red]parseInt[/red](value[red],10[/red]).toFixed([red]2[/red]).replace(/\./,'')

Feherke.
 
Is there a way to have both of these functions work at the same time?

result=Number(value).toFixed(2).replace(/\./,'')
result=parseInt(value,10).toFixed(2).replace(/\./,'')
 
my data has this type of value

630
630X
630.12
630.01X
630.01V
 
Hi

As I understand you want to format them as follows :
[tt]
630 [small]->[/small] 63000
630X [small]->[/small] 63000
630.12 [small]->[/small] 63012
630.01X [small]->[/small] 63001
630.01V [small]->[/small] 63001
[/tt]
In that case my last code is what you need.

Feherke.
 
Yes it works great. Thanks a lot you are very helpful

I have one more question this should be the last one
I have another field with values

example
01.0302 -> 010302
24.0102 -> 240102
01. -> 010000
20.05 -> 200500

 
Let's say your number is "n".
var intpart=n.toString().split('.')[0]
var fracpart=n.toString().split('.')[1]
fracpart=(fracpart + '0000').substr(0,4)
n=(intpart + fracpart)


_________________
Bob Rashkin
 
carranz,

Don't forget the 'Thank nnnn for this valuable post' link below each post.

Looking at your stats, I get the impression you weren't aware of it.

Dan



Coedit Limited - Delivering standards compliant, accessible web solutions

Dan's Page [blue]@[/blue] Code Couch:
Code Couch Tech Snippets & Info:
 
Hi

If Bob reduces the number of [tt]split()[/tt] calls, his method will be definitely faster than mine. But probably it is already.

Just to keep the "tradition" of this thread, here is a [tt]toFixed()[/tt] & [tt]replace()[/tt] alternative :
Code:
result=('0000'+parseFloat(value).toFixed(4)).replace(/\./,'').replace(/.*(.{6})$/,'$1')

Feherke.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top