SCAN not working
SCAN not working
I'm not sure what I'm missing here, but I'm using the following to filter out a listing of accounts:
# Get principle element name instead of using alias
sTM1Acct = GetPrincipleElementName('All_IS_Account', v4) ;
# Filter out non general ledger accounts
# Scan(substring, string)
If (Scan('Case Sale', sTM1Acct) > 0) ;
ItemSkip;
EndIf:
This seems pretty straightforward, however, it is not filtering out the accounts with case sale in the name. For example, for the sTM1Acct = 'TOTAL CASE SALES', the result is 0 (I output to an ASCII file to verify what the result was in TI) instead of.
I know that Scan is a pretty basic function so I'm surely just missing something very obvious. I'm using 9.1 SP3 (Build: 9.1.30000.340). Thanks for your help.
# Get principle element name instead of using alias
sTM1Acct = GetPrincipleElementName('All_IS_Account', v4) ;
# Filter out non general ledger accounts
# Scan(substring, string)
If (Scan('Case Sale', sTM1Acct) > 0) ;
ItemSkip;
EndIf:
This seems pretty straightforward, however, it is not filtering out the accounts with case sale in the name. For example, for the sTM1Acct = 'TOTAL CASE SALES', the result is 0 (I output to an ASCII file to verify what the result was in TI) instead of.
I know that Scan is a pretty basic function so I'm surely just missing something very obvious. I'm using 9.1 SP3 (Build: 9.1.30000.340). Thanks for your help.
-
- Community Contributor
- Posts: 126
- Joined: Sun Jun 29, 2008 9:33 am
- OLAP Product: TM1
- Version: 10.2.2
- Excel Version: 2016
- Location: Karlsruhe
Re: SCAN not working
it works with
DimensionElementPrincipalName
and an ; after your endif
Regards,
M.
DimensionElementPrincipalName
and an ; after your endif

Regards,
M.
-
- MVP
- Posts: 3698
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: SCAN not working
Your problem is that the SCAN function violates the general TM1 principal of case insensitivity.
Try this:
If (Scan('CASE SALE', Upper(sTM1Acct)) > 0);
ItemSkip;
EndIf;
Try this:
If (Scan('CASE SALE', Upper(sTM1Acct)) > 0);
ItemSkip;
EndIf;
-
- Site Admin
- Posts: 1458
- Joined: Wed May 28, 2008 9:09 am
Re: SCAN not working
My view would be that TM1 is case insensitive as regards _code_ (rules and TI) but not as regards _data_. After all, one does, sometimes, want to distinguish 'a' and 'A'.
-
- Site Admin
- Posts: 6645
- 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: SCAN not working
I would agree. However it's disturbing that TM1 can be a tad inconsistent on what's a match and what's not. A direct comparison of two string variable values is not case sensitive, for example, as s1 in the code below shows. And yet this would also be data.David Usherwood wrote:My view would be that TM1 is case insensitive as regards _code_ (rules and TI) but not as regards _data_. After all, one does, sometimes, want to distinguish 'a' and 'A'.
While on the subject of such inconsistencies, Scan (as an example) is also space sensitive (which I would concur that it should be), and yet as we know a straight comparison of variable values is not (s2 in the example below).
Code: Select all
# Will return 4
l1 = Scan ( 'def', 'abcdef');
# Will return 0
l2 = Scan ( 'def', 'ABCDEF');
#Will return 0
l3 = Scan ('def', 'a b c d e f');
# Will return Match
If ( 'def' @= 'DEF');
s1 = 'Match';
Else;
s1 = 'No Match';
EndIf;
# Will return Match
If ( 'def' @= 'd e f ');
s2 = 'Match';
Else;
s2 = 'No Match';
EndIf;
#Proof
AsciiOutput ('F:\Temp\Outputs.txt', NumberToString (l1), NumberToString (l2), NumberToString (l3), s1, s2 );
"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.
- Steve Vincent
- Site Admin
- Posts: 1054
- Joined: Mon May 12, 2008 8:33 am
- OLAP Product: TM1
- Version: 10.2.2 FP1
- Excel Version: 2010
- Location: UK
Re: SCAN not working
Just got caught by this myself, the help files make no mention of case sensitivity;
I will raise a request with IBM to get the documentation updated because next to nothing else in TM1 gives 2 hoots about case and it is important people know about it. Yet another inconsistancy in the way inbuilt functions are handled :/SCAN
This is a TM1® rules function, valid in both TM1 rules and TurboIntegrator processes.
SCAN returns a number indicating the starting location of the first occurrence of a specified substring within a given string. If the substring does not occur in the given string, the function returns zero.
Syntax
SCAN(substring, string)
Argument
Description
substring
The substring you are trying to locate.
string
The string within which you are searching for the substring.
Example
SCAN('scribe', 'described') returns 3.
If this were a dictatorship, it would be a heck of a lot easier, just so long as I'm the dictator.
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
Production: Planning Analytics 64 bit 2.0.5, Windows 2016 Server. Excel 2016, IE11 for t'internet
-
- MVP
- Posts: 600
- Joined: Wed Aug 17, 2011 1:19 pm
- OLAP Product: TM1
- Version: 9.5.2 10.1 10.2
- Excel Version: 2003 2007
- Location: York, UK
Re: SCAN not working
Does anyone know of any other functions apart from SCAN that are case and space sensitive? It would seem to make sense to present a comprehensive list.
-
- Site Admin
- Posts: 6645
- 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: SCAN not working
So are Long and SubSt.Andy Key wrote:Filter by Wildcard in subset editor is space sensitive.
Back on the subject of case sensitivity, the arguments to TimSt are as well.
I've been meaning to add these to my Documentation Deficiencies thread and will do so when I get a chance.
"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.