Page 1 of 1

Rounding in TM1

Posted: Tue May 19, 2009 3:02 pm
by nicesloper
Hi all, is there any possibility to create a rule for doing rounding without the usage of following functions ROUND and ROUNDP? Or is it possible to do coding to solve this problem? The problem I am faced is, to do roundings for elements like costs and revenues. There are only two digits allowed after the comma (eg. 1,43 or 300,04). The digits are also supposed to be represented in a commercial way - that means <5 is smaller, >=5 is greater (eg. 1,445 is 1,45 and 1,443 is 1,44). Do there exist any solutions?
Thanks a lot in advance! Nicesloper

Re: Rounding in TM1

Posted: Tue May 19, 2009 3:30 pm
by David Usherwood
a What's so awful about using round/roundp? It's not as if we are drowning in standard functions, but...

b I think you can do it with int((x * 100 + 0.5)/100). Need to think about negative numbers - believe the convention is to round towards zero.

Re: Rounding in TM1

Posted: Tue May 19, 2009 4:18 pm
by nicesloper
it's not awful, but I didn't and don't see a possibility in solving my problem. If I want to create a rule with round/roundp - the tm1 handbook tells me to insert a number "round(1,46,1)" in the rules editor. This works fine. But isn't it possible like in Excel to use a function like ROUND(B10;2) without knowing the real value? So I could just adjust all values in the row or column, which have the same element.
Thanks a lot once more! Nicesloper

Re: Rounding in TM1

Posted: Tue May 19, 2009 6:34 pm
by Steve Rowe
Hi Nicesloper,

I think your taking the example a little too literally!

You can use the function to round any expression to whatever you need...

I'm now wondering if I've been trolled but some ex-colleagues trying to demonstrate how bad the help is in places......
errr Cheers

Re: Rounding in TM1

Posted: Tue May 19, 2009 6:36 pm
by Martin Ryan
You mean you're literally writing the rule "round(1,46, 2);" ?

I suggest you take a closer look at the rules manual. There should never be a time when you actually write the number in the rule. As Steve implies, your rule should be more like
['Rounded'] = N: round(['Non rounded'], 2);

Where Rounded is one element and Non Rounded is another element.

Cheers,
Martin

Re: Rounding in TM1

Posted: Tue May 19, 2009 10:39 pm
by Alan Kirk
Steve Rowe wrote:I'm now wondering if I've been trolled but some ex-colleagues trying to demonstrate how bad the help is in places......
I foresee a sizeable number of threads in our future, then...

Especially when they get started on the API manuals. :roll:

Re: Rounding in TM1

Posted: Tue May 19, 2009 11:40 pm
by David Usherwood
Troll, moi? Just get your billy goats over the bridge double quick!

Re: Rounding in TM1

Posted: Wed May 20, 2009 12:09 pm
by nicesloper
Thanks a lot for the quick help you all. I tried and it worked, using elements and not numbers. But is it possible, just to get a rounded result in the same row or column of a table (eg. row "cost" with three columns: 1,1234 / 3,7891 / 5,6549 then doing the rounding and in the same row "cost" the result is 1,12 / 3,79 / 5,65)?
As I try ['Rounded'] = N: round(['rounded'], 2); I get a #NV message in the table. But it doesn't make any sense to me to put the results in an other element using ['Rounded'] = N: round(['Non rounded'], 2);

Thanks a lot for help in advance! Nicesloper

Re: Rounding in TM1

Posted: Wed May 20, 2009 2:51 pm
by Steve Rowe
['Rounded'] = N: round(['rounded'], 2); is circular and will never work.

To get non-rounded to decimal values, you have some options.
1. Use formatting, you can use excel type formats to give the apprearence of numbers in thousands.
2. If it is a rule based value then put the round function around the rule that calculates the non-rounded value.
3. If it is raw data then round it during the data load.

Note though that TM1 stores it's values as binary floating point values, and that there are some decimal to 2 d.p. values that are impossible to store exactly in binary floating point. This is why you sometimes see things like 210.19999999999 instead of 210.20

http://en.wikipedia.org/wiki/Floating_point

HTH