Page 1 of 1

Rounding From Decimal to Integer In PX

Posted: Wed Jun 20, 2007 3:00 pm
by dtatem
I have a decimal value ie 3763.8 and I want to convert to an Integer with Rounding to the next number. Therefore the expected integer value I should get is 3764. Likewise if my decimal value is 2314.2, the integer value I should get is 2314.

I have looked through the various postings but I didn't find anything that seem to work. Currently I am using AsInteger(Link.ColName)

Please let me know..

Thanks

dtatem

Posted: Wed Jun 20, 2007 3:17 pm
by us1aslam1us
Use an explicit conversion function such as int32_from_decimal in a Modify stage.

Posted: Wed Jun 20, 2007 4:12 pm
by JoshGeorge
If you map your decimal directly to an integer field of the same length rounding should happen implicitly the way you want.

Posted: Wed Jun 20, 2007 4:21 pm
by dtatem
If I map the decimal to an integer field as you suggested, would I get a warning and If I do how do I suppress the warning message?

Thanks..

dtatem

Posted: Wed Jun 20, 2007 4:28 pm
by JoshGeorge
Did you try? I'm not getting any warning in my jobs :)

Posted: Wed Jun 20, 2007 4:39 pm
by I_Server_Whale
dtatem wrote:how do I suppress the warning message?

Thanks..

dtatem
You could use message handlers to suppress or demote warning messages. More information can be found in chapter 6 of the Director guide or search the forum for discussions on the same.

Whale.

Posted: Wed Jun 20, 2007 4:57 pm
by ray.wurlod
That's not the same as not generating the warnings in the first place!
When you use the Modify stage add an additional specification containing the single word NOWARN.
This is not in the Parallel Job Developer's Guide but you can find it in the Orchestrate Operators manual.

Posted: Wed Jun 20, 2007 6:43 pm
by dtatem
JoshGeorge:

I haven't tried it as yet. To give you more information,the decimal values I posted earlier,are derived from an input declared as Dec(10,2). The input dec(10,2) are passed into the aggregate stage. The "Sum Output Column" data type is defaulting to "DOUBLE", I then use a transformer to cast the result from DOUBLE to Integer.. ie AsInteger(Link.Colname).

Should I make the data type length to Integer(10)?

--dtatem

Posted: Wed Jun 20, 2007 10:36 pm
by ray.wurlod
Integer doesn't have a length. Data type int32 is always four bytes long. If your aggregated numbers are larger than this, you can use int64.

Posted: Wed Jun 20, 2007 11:16 pm
by JoshGeorge
Output type of calculation column is normally double, but you can default (override) this to decimal in the aggregator. You can see this option in the properties - Available properties to add. Now as noted earlier in the transformer you can map your decimal directly to an integer field of the same length. You shouldn't get any error/ warning messages for this.