Rounding in TM1

Post Reply
nicesloper
Posts: 3
Joined: Wed May 13, 2009 8:34 am
Version: 90 SP3
Excel Version: 2003

Rounding in TM1

Post 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
David Usherwood
Site Admin
Posts: 1454
Joined: Wed May 28, 2008 9:09 am

Re: Rounding in TM1

Post 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.
nicesloper
Posts: 3
Joined: Wed May 13, 2009 8:34 am
Version: 90 SP3
Excel Version: 2003

Re: Rounding in TM1

Post 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
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Rounding in TM1

Post 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
Technical Director
www.infocat.co.uk
User avatar
Martin Ryan
Site Admin
Posts: 1988
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Rounding in TM1

Post 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
Please do not send technical questions via private message or email. Post them in the forum where you'll probably get a faster reply, and everyone can benefit from the answers.
Jodi Ryan Family Lawyer
User avatar
Alan Kirk
Site Admin
Posts: 6606
Joined: Sun May 11, 2008 2:30 am
OLAP Product: TM1
Version: PA2.0.9.18 Classic NO PAW!
Excel Version: 2013 and Office 365
Location: Sydney, Australia
Contact:

Re: Rounding in TM1

Post 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:
"To them, equipment failure is terrifying. To me, it’s 'Tuesday.' "
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
David Usherwood
Site Admin
Posts: 1454
Joined: Wed May 28, 2008 9:09 am

Re: Rounding in TM1

Post by David Usherwood »

Troll, moi? Just get your billy goats over the bridge double quick!
nicesloper
Posts: 3
Joined: Wed May 13, 2009 8:34 am
Version: 90 SP3
Excel Version: 2003

Re: Rounding in TM1

Post 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
User avatar
Steve Rowe
Site Admin
Posts: 2417
Joined: Wed May 14, 2008 4:25 pm
OLAP Product: TM1
Version: TM1 v6,v7,v8,v9,v10,v11+PAW
Excel Version: Nearly all of them

Re: Rounding in TM1

Post 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
Technical Director
www.infocat.co.uk
Post Reply