In Turbo Integrator, I need to delete specific character from a String.
For example if my string is 100.200.12345 or 12.123.12345
then I would like to get rid of . (DOT) from the srings and it should look like as: 10020012345 or 1212312345
Please note that . (DOT) may appear after any number of characters.
I tired to use the DELET() and SCAN() but its not making sense to me.
Can someone please help!
Thanks!
Delete characters from String
- rkaif
- Community Contributor
- Posts: 328
- Joined: Fri Sep 05, 2008 6:58 pm
- OLAP Product: IBM Cognos TM1
- Version: 9.1 or later
- Excel Version: 2003 or later
Re: Delete characters from String
You may use WHILE loop to get rid of . (DOT)
See this code:
Hope it helps!
See this code:
Code: Select all
iClean = 0;
WHILE ( iClean <> 1 );
iPos = SCAN ( '.', dimVariable );
IF ( iPos <> 0 );
dimVariable = DELET (dimVariable , iPos, 1 );
ELSE;
iClean = 1;
ENDIF;
END;
#Test
ASCIIOutput(fileName, dimVariable);
Cheers!
Rizwan Kaif
Rizwan Kaif
-
- Posts: 27
- Joined: Wed Mar 17, 2010 2:41 pm
- OLAP Product: TM1, Transformer, EP, MSAS
- Version: 2.0.6
- Excel Version: 2016
- Location: Russian Federation
Re: Delete characters from String
It is actual for tabs (Prolog, Metadata, Data, Epilog) of TI, But if i should create variable with formula?
-
- MVP
- Posts: 195
- Joined: Wed Jul 22, 2009 10:35 pm
- OLAP Product: TM1
- Version: 9.5.2 FP3
- Excel Version: 2010
Re: Delete characters from String
Do you mean in Rules?
Loop in TI is great, as it is universal - you may have as many dots inside as you want - it will just work.
If you want to do it via Rules then it is not that elegant, but you can do it if there is a known maximum of dots (e.g. not more than 2).
In such a case you can create a rule like in my example below (what I actually did is I wrote a rule for tekst2 that takes rid of first dot in tekst1, then if you have a maximum of two dots you add a tekst3 that does the same with tekst2, as we can see you can easily expand it in case of larger amount of dots).
If you want, you can try to type it in one rule but then it gets even more non-elegant.
The rule is like this (I used attributes cube for this example):
As you can see in the picture below, it works independently of where the dots are (elements a and b), it does not matter if there are less dots (elements c and d), if the dots are at the beginning or end of a string (element e) but in my case dots remain if there are more than two of them (element f).
HTH
Loop in TI is great, as it is universal - you may have as many dots inside as you want - it will just work.
If you want to do it via Rules then it is not that elegant, but you can do it if there is a known maximum of dots (e.g. not more than 2).
In such a case you can create a rule like in my example below (what I actually did is I wrote a rule for tekst2 that takes rid of first dot in tekst1, then if you have a maximum of two dots you add a tekst3 that does the same with tekst2, as we can see you can easily expand it in case of larger amount of dots).
If you want, you can try to type it in one rule but then it gets even more non-elegant.
The rule is like this (I used attributes cube for this example):
Code: Select all
['tekst2']=S:
SUBST(
DB('}ElementAttributes_aa',!aa,'tekst1'),
1,
SCAN('.', DB('}ElementAttributes_aa',!aa,'tekst1'))-1)
|
SUBST(
DB('}ElementAttributes_aa',!aa,'tekst1'),
SCAN('.', DB('}ElementAttributes_aa',!aa,'tekst1'))+1,
LONG(DB('}ElementAttributes_aa',!aa,'tekst1')));
['tekst3']=S:
SUBST(
DB('}ElementAttributes_aa',!aa,'tekst2'),
1,
SCAN('.', DB('}ElementAttributes_aa',!aa,'tekst2'))-1)
|
SUBST(
DB('}ElementAttributes_aa',!aa,'tekst2'),
SCAN('.', DB('}ElementAttributes_aa',!aa,'tekst2'))+1,
LONG(DB('}ElementAttributes_aa',!aa,'tekst2')));
HTH
- Attachments
-
- view.JPG (24.14 KiB) Viewed 6504 times