Page 1 of 1
NUMBR conversion
Posted: Tue May 30, 2017 1:10 pm
by Mark RMBC
Hi all,
I have a TI process that does a while loop over a periods dimension. The dimension has in it elements that represent the period number, so 01,02,03…12. There are also a few other elements, called Annual Total, Adjustment.
When I ran the TI process there was an error saying, “Cannot convert string "Adjustment" to a real number”, which didn’t surprise me as the TI included a Numbr conversion against the elements in the periods dimension so it obviously can’t convert the word Adjustment to a number.
The puzzling thing is it doesn't throw up the same error for Annual Total. Any ideas why?
Re: NUMBR conversion
Posted: Tue May 30, 2017 1:57 pm
by gtonkin
Any aliases on the dimension-if so what are they defined as and what values do they have for Annual Total?
What value is returned after the NUMBR function on Annual Total?
Edit: Looks like Annual Total is a red herring - other strings seems to return a value of zero - Tested with Aardvark, Banana and Zoo-Seems like it does not like "Adjusted" or "Adjustment" - Adjust is fine and so is Adjusts.
Happy fiddling on this one!
Re: NUMBR conversion
Posted: Tue May 30, 2017 2:43 pm
by Mark RMBC
Hi gtonkin,
Yeah I had already looked at the attributes and there were no differences that made me think that was the issue.
I took your approach and tested on some words and had the following results:
Apple - Couldn't convert
Adjustment - Couldn't convert
Annual - Could Convert
Annual Total - Could Convert
Basement - Couldn't convert
Adventure - Couldn't convert
I will put this down as a mystery I won't bother thinking about ever again, except I will ensure any Numbr conversion coding excludes words just to be on the safe side!
Additional: I guess I should add when I Asciioutput the results there is 0 for every element in the dimension
cheers, Mark
Re: NUMBR conversion
Posted: Tue May 30, 2017 3:37 pm
by Wim Gielis
Hello Mark,
See:
http://www.wimgielis.com/tm1_numbersandstrings_EN.htm
NUMBR
- Arguments:
A string
- Input: you must use . (period) as the decimal separator and , (comma) as the thousands separator
- Output: All characters other than '0' through '9', '+', '-', ',', '.'
and 'E' are ignored.
So E (and also e) are not ignored, but TM1 cannot resolve it to a valid number, hence the error message.
It's used in scientific notation.
Your list of words that can or cannot be converted, respects this rule.
Re: NUMBR conversion
Posted: Tue May 30, 2017 3:54 pm
by Mark RMBC
Wim,
That totally explains it! Thanks a lot.
I was starting to think it was some sort of reserved word issue but then I thought Aardvark can't be a reserved can it!
How you managed to work that out is now the mystery!
Incidentally - soccer and TM1, a man after my own heart! Though I would call it football!
cheers, Mark
Re: NUMBR conversion
Posted: Tue May 30, 2017 4:03 pm
by gtonkin
Thanks too Wim-guess the elements that failed have a pattern they all contain the letter "E" which it probably tries to convert from scientific notation.
Re: NUMBR conversion
Posted: Tue May 30, 2017 5:25 pm
by Wim Gielis
You're welcome. I looked at the string and applied Numbr to a word that became shorter and shorter, character after character, until only the "e" remained. Then I looked at my own page and the penny dropped
