SCAN not working

Post Reply
ccierpik
Posts: 16
Joined: Thu May 15, 2008 12:59 pm

SCAN not working

Post by ccierpik »

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.
Marcus Scherer
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

Post by Marcus Scherer »

it works with

DimensionElementPrincipalName

and an ; after your endif ;)

Regards,

M.
lotsaram
MVP
Posts: 3652
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

Post by lotsaram »

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;
David Usherwood
Site Admin
Posts: 1454
Joined: Wed May 28, 2008 9:09 am

Re: SCAN not working

Post by David Usherwood »

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'.
User avatar
Alan Kirk
Site Admin
Posts: 6606
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

Post by Alan Kirk »

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'.
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.

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.
User avatar
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

Post by Steve Vincent »

Just got caught by this myself, the help files make no mention of case sensitivity;
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.
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 :/
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
Duncan P
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

Post by Duncan P »

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.
Andy Key
MVP
Posts: 351
Joined: Wed May 14, 2008 1:37 pm
OLAP Product: TM1
Version: 2.5 to PA
Excel Version: Lots
Location: Sydney
Contact:

Re: SCAN not working

Post by Andy Key »

Filter by Wildcard in subset editor is space sensitive.
Andy Key
User avatar
Alan Kirk
Site Admin
Posts: 6606
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

Post by Alan Kirk »

Andy Key wrote:Filter by Wildcard in subset editor is space sensitive.
So are Long and SubSt.

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.
Post Reply