If you are unable to create a new account, please email support@bspsoftware.com

 

News:

MetaManager - Administrative Tools for IBM Cognos
Pricing starting at $2,100
Download Now    Learn More

Main Menu

Problems with decimals and percentage

Started by CognosBen, 25 Nov 2016 06:40:37 AM

Previous topic - Next topic

CognosBen

I'm trying to convert the value 0,906 to 0,91

Changing the data type and setting max two decimals will not help me since I'm going to do a calculation based on the two data fields.
When I'm doing a calculation to see the difference in percentage in the example below, I will get 1% difference, and that looks very strange since both values are on 91% with 2 decimals.

Value 1: 0,906 | 91%
Value 2: 0,913 | 91%
Value 2 - Value 1 = 0,007 | 1%

I have tried to use Cast((0.906) as numeric(5,2)) and Cast((0.906) as numeric(5,2))
In SQL, this will return 0.91, but in Cognos this returns 0.9

Does anyone know why? And know how I can fix this?

HalfBloodPrince

Try abs(0.906) and check  if you get the desired result.

CognosBen


hespora

#3
Am I missing the obvious?

_round([value],2)

should do exactly what you want as a cognos function, or round([value],2) for pretty much any vendor's db function. Casting is for datatype conversions and should not change your value.

CognosBen

Quote from: hespora on 25 Nov 2016 07:55:50 AM
Am I missing the obvious?

_round([value],2)

should do exactly what you want as a cognos function, or round([value],2) for pretty much any vendor's db function. Casting is for datatype conversions and should not change your value.


Thanks!! You are my hero! :)

hespora

You're welcome; glad I could help! :)