Hi,
I'm using TM1 9.5 and writting a new TI process for data import.
The system I'm importing from is a single ledger system and therefore when I extract the data it shows all the nominals with balances but also all of the debtor/creditor accounts. All of the dr and cr accounts begin with a letter whereas all of the nominal accounts start with a number.
I'd like to consolidate the dr and cr accounts by using a if formula to ascertain whether the string starts wiht a letter or a number. Does such a function exist in the functions, I can't see one?
Regards
Tom
Is it text or number (TI Question)
-
- Site Admin
- Posts: 1458
- Joined: Wed May 28, 2008 9:09 am
Re: Is it text or number (TI Question)
I'd suggest picking up the first character using subst(xxx,1,1) and testing whether it is between 0 and 9 inclusive.
-
- 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: Is it text or number (TI Question)
You can use the Code Rules function to determine the ASCII code of the first character. If the code falls between 48 and 57 inclusive, it's a digit.TomHine wrote:Hi,
I'd like to consolidate the dr and cr accounts by using a if formula to ascertain whether the string starts wiht a letter or a number. Does such a function exist in the functions, I can't see one?
Edit: 3 independent replies within 4 minutes. That's service with a smile.
(David beat me only because the Reference guide was really slow to provide the link tonight.

"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.
-----------
Before posting, please check the documentation, the FAQ, the Search function and FOR THE LOVE OF GLUB the Request Guidelines.
-
- MVP
- Posts: 3241
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.1.5
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: Is it text or number (TI Question)
Hi Tom
or:
Code: Select all
If(Code(youraccount,1)>=48 & Code(youraccount,1)<=57);
# this is a number
EndIf;
Code: Select all
If(Subst(youraccount,1,1)>='0' & Subst(youraccount,1,1)<='9');
# this is a number
EndIf;
Best regards,
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- MVP
- Posts: 3241
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.1.5
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: Is it text or number (TI Question)
Or another variation:
Code: Select all
If(Scan(Subst(youraccount,1,1),'0123456789')>0);
# this is a number
EndIf;
Best regards,
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Wim Gielis
IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
-
- MVP
- Posts: 3706
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Is it text or number (TI Question)
Awesome code snippet.Wim Gielis wrote:Or another variation:
Code: Select all
If(Scan(Subst(youraccount,1,1),'0123456789')>0); # this is a number EndIf;
-
- Regular Participant
- Posts: 173
- Joined: Sat Mar 20, 2010 3:03 pm
- OLAP Product: TM1
- Version: 9.5.2
- Excel Version: 2007-10
Re: Is it text or number (TI Question)
If you wanted to check the whole string one way might be:-
Code: Select all
sTestString = '1234a';
nStringPos = 0;
While(nStringPos < Long(sTestString) & nStringPos > -1);
nStringPos = nStringPos + 1;
If(Scan(SubSt(sTestString, nStringPos, 1), '0123456789') = 0);
nStringPos = -1;
EndIf;
End;
If(nStringPos > 0);
# This is a number.
EndIf;