Defining Characters

Post Reply
Devx
Posts: 2
Joined: Wed Jan 30, 2013 12:00 am
OLAP Product: Cognos TM1
Version: 9.5.2
Excel Version: 2010

Defining Characters

Post by Devx »

I am writing a TI to load Attributes against an inventory item number in a dimension, but the data I want to load has trailing spaces, I have tried TRIM to remove these but after doing a ASCII extract to see the data I have found there is a "?" following the spaces.

This is creating issues with the Dimension and I want to be able to define this Character so that I can either remove it or make the attribute blank if it exists.

Is there any code that can be used to define a character at the end of a string?

Thanks
User avatar
Martin Ryan
Site Admin
Posts: 2003
Joined: Sat May 10, 2008 9:08 am
OLAP Product: TM1
Version: 10.1
Excel Version: 2010
Location: Wellington, New Zealand
Contact:

Re: Defining Characters

Post by Martin Ryan »

"?" can mean unprintable characters, but if you simply want to get rid of the last character in a string then "myStr=subst(myStr, 1, long(myStr)-2);" should do it (I think it's -2, not -1, but I may be mis-remembering). Then you can wrap a trim around that to get rid of the spaces.

HTH,
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
Alan Kirk
Site Admin
Posts: 6667
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: Defining Characters

Post by Alan Kirk »

Dollars to donuts it's one of those accursed HTML non-breaking spaces. They're commonly picked up if the data source was originally a web page and unfortunately most Trim() type functions don't kill them.

The Ascii code is 160; you could use the Char() rules function to generate the character and feed it to the Scan() function to check for its presence in the data string. If you find it in the string then you could use the SubSt function suggested by Martin to rip out only the part of the string that is not the non-breaking space. I haven't tested this but it should work in theory.
"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.
Devx
Posts: 2
Joined: Wed Jan 30, 2013 12:00 am
OLAP Product: Cognos TM1
Version: 9.5.2
Excel Version: 2010

Re: Defining Characters

Post by Devx »

Alan / Martin

Thanks for your response, that has put me on the right track.
Post Reply