Need Help
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Need Help
Refer to the image below (data received in.csv file)
Can somebody help me on how to create a subset called 'CostElement' and later insert 2 subsets (Operating Cost and Non-Operating Cost).
For Operating Cost, the should be 4 subsets (Internal Gas Consumption, Plant Utilities, Repair & Maintenance, Material & Supplies)
For Plant Utilities and 'Repair & maintenance', each have one element but for 'Internal Gas Consumption' and 'Material & Supplies', there are still another consolidation then only elements.
The file that i received is in .csv format.
The other concern is; as the above figure, the elements mostly ends at row DESC_L6. There are also possibility that they may have more elements to be added later.
Please help as i am very new to TI programming.
Thank you.
Can somebody help me on how to create a subset called 'CostElement' and later insert 2 subsets (Operating Cost and Non-Operating Cost).
For Operating Cost, the should be 4 subsets (Internal Gas Consumption, Plant Utilities, Repair & Maintenance, Material & Supplies)
For Plant Utilities and 'Repair & maintenance', each have one element but for 'Internal Gas Consumption' and 'Material & Supplies', there are still another consolidation then only elements.
The file that i received is in .csv format.
The other concern is; as the above figure, the elements mostly ends at row DESC_L6. There are also possibility that they may have more elements to be added later.
Please help as i am very new to TI programming.
Thank you.
- Attachments
-
- sampleData.JPG (186.21 KiB) Viewed 15585 times
vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
-
- MVP
- Posts: 1831
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: Need Help
Subsets can not exist within other subset... a subset is merely a view or subsection of elements within a dimension.
Is it the creation of the dimension that you are in fact wanting to achieve (with Operating Cost being a Consolidated element that contains other consolidated elements Internal Gas Consumption etc)?
Is it the creation of the dimension that you are in fact wanting to achieve (with Operating Cost being a Consolidated element that contains other consolidated elements Internal Gas Consumption etc)?
Declan Rodger
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
sorry for the miscommunication.
Yes, its a dimension called 'CostElement'
within the dimension, there'll be two consolidation Operating Cost and Non-Operating Cost.
The rest will continuously become consolidation until it reaches the last column whereby it will become element.
Please help me with the coding.
Should the coding be under metadata or data?
Yes, its a dimension called 'CostElement'
within the dimension, there'll be two consolidation Operating Cost and Non-Operating Cost.
The rest will continuously become consolidation until it reaches the last column whereby it will become element.
Please help me with the coding.
Should the coding be under metadata or data?
vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
-
- MVP
- Posts: 1831
- Joined: Mon Dec 05, 2011 11:51 am
- OLAP Product: Cognos TM1
- Version: PA2.0 and most of the old ones
- Excel Version: All of em
- Location: Manchester, United Kingdom
- Contact:
Re: Need Help
Changes to structure should be carried out in the metadata tab.
DimensionElementInsert()
DimensionElementComponentAdd()
Can be found in the reference guide and will get you most of the way to what you want to do.
If you intend to run the TI multiple times in order to catch new accounts in the future I would add a simple if statement that checks if the lowest level item exists under the CostElement hierarchy with ELISANC() and if so use the ItemSkip function.
DimensionElementInsert()
DimensionElementComponentAdd()
Can be found in the reference guide and will get you most of the way to what you want to do.
If you intend to run the TI multiple times in order to catch new accounts in the future I would add a simple if statement that checks if the lowest level item exists under the CostElement hierarchy with ELISANC() and if so use the ItemSkip function.
Declan Rodger
- Steve Rowe
- Site Admin
- Posts: 2464
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: Need Help
The structure of the file you have is an extremely horrid way of describing a dimension structure. Still what can you do that’s not really your problem….
Irrespective of the above I think your TI script looks something like the following. What we are trying to do is work with the columns in pairs and just work with the parent child relationship described. It’s all untested and parsed so it might have a few syntax issues.
You’ll also need to make sure you ignore anywhere the null value is encountered in a field. All the below goes in the Metadata tab once you have set the file up as your datasource, set the field headers up to be variables of the string type and "other"
Irrespective of the above I think your TI script looks something like the following. What we are trying to do is work with the columns in pairs and just work with the parent child relationship described. It’s all untested and parsed so it might have a few syntax issues.
You’ll also need to make sure you ignore anywhere the null value is encountered in a field. All the below goes in the Metadata tab once you have set the file up as your datasource, set the field headers up to be variables of the string type and "other"
Code: Select all
sElType=’N’;
sInsertionPoint=’’;
sDimName=’Your Dim Name Here’;
nElWeight=1;
#Parent Child relationship 1
sParent=DESC_L3;
sChild=DESC_L4;
#Check for no Nulls
If ( ~Scan ( ‘Null’ , sParent | sChild ) >0);
DimensionElementInsert(sDimName, sInsertionPoint, sParent, sElType);
DimensionElementInsert(sDimName, sInsertionPoint, sChild, sElType);
DimensionElementComponentAdd(sDimName, sParent, sChild, nElWeight);
EndIf;
#Parent Child relationship 2
sParent=DESC_L4;
sChild=DESC_L5;
#Check for no Nulls
If ( ~Scan ( ‘Null’ , sParent | sChild ) >0);
DimensionElementInsert(sDimName, sInsertionPoint, sParent, sElType);
DimensionElementInsert(sDimName, sInsertionPoint, sChild, sElType);
DimensionElementComponentAdd(sDimName, sParent, sChild, nElWeight);
EndIf;
#Parent Child relationship 3
sParent=DESC_L5;
sChild=DESC_L6;
#Check for no Nulls
If ( ~Scan ( ‘Null’ , sParent | sChild ) >0);
DimensionElementInsert(sDimName, sInsertionPoint, sParent, sElType);
DimensionElementInsert(sDimName, sInsertionPoint, sChild, sElType);
DimensionElementComponentAdd(sDimName, sParent, sChild, nElWeight);
EndIf;
#Parent Child relationship 4
sParent=DESC_L6;
sChild=DESC_L7;
#Check for no Nulls
If ( ~Scan ( ‘Null’ , sParent | sChild ) >0);
DimensionElementInsert(sDimName, sInsertionPoint, sParent, sElType);
DimensionElementInsert(sDimName, sInsertionPoint, sChild, sElType);
DimensionElementComponentAdd(sDimName, sParent, sChild, nElWeight);
EndIf;
Technical Director
www.infocat.co.uk
www.infocat.co.uk
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
Wow.. thank you so much!
I will try it soon!!!

I will try it soon!!!





vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
- Olivier
- Community Contributor
- Posts: 159
- Joined: Thu Jun 26, 2008 5:46 am
- OLAP Product: TM1
- Version: Tm1 10.2.2fp4 -> 2.09
- Excel Version: Excel 2013 - 2019
- Location: Sydney
Re: Need Help
Actually, copying a subset into a subset results in generating a user defined consolidationSubsets can not exist within other subset... a subset is merely a view or subsection of elements within a dimension.

This has nothing to do with the original question once decrypted but worth reminding.
Tm1 User guide page 45 :
Hope this helps,Adding a User-Defined Consolidation to a Subset
You can create a user-defined consolidation that is different from the consolidations in a dimension
structure. To create a user-defined consolidation, you insert one subset into another subset. The
members of the inserted subset are rolled up into a consolidated element (user-defined consolidation)
that has same name as the source subset. For example, if you insert the subset MySalesArea into
the subset Europe, TM1 adds the user-defined consolidation MySalesArea to Europe
HTH
Olivier
Olivier
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
hai,
tried the code.. the error occurs only on the last loop on on the last relationship. happens before. not sure why.
attached is the output of the coding... it stills pickup the 'NULL's as element.
tried the code.. the error occurs only on the last loop on
Code: Select all
DimensionElementComponentAdd(sDimName, sParent, sChild, nElWeight);
attached is the output of the coding... it stills pickup the 'NULL's as element.
- Attachments
-
- The Output
- output1.JPG (55.21 KiB) Viewed 15512 times
vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
-
- MVP
- Posts: 352
- Joined: Wed May 14, 2008 1:37 pm
- OLAP Product: TM1
- Version: 2.5 to PA
- Excel Version: Lots
- Location: Sydney
- Contact:
Re: Need Help
The Scan function is case sensitive, so replace Null in Steve's code with NULL, clear out your dimension and run the code again.
Andy Key
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
Thanks!
btw, i just discover on the ~Scan code..
can someone elaborate more on this?

btw, i just discover on the ~Scan code..
can someone elaborate more on this?
vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
I really appreciate all the helps above. This topic can be closed.
SOLVED!!! WoooHooo!!!

SOLVED!!! WoooHooo!!!



vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
-
- 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: Need Help
Scan() is a Rules function that you can use to determine whether one string (a substring) is found inside another string. You can find more about it in the TM1 Reference Guide under Rules Functions -> Text Rules Functions:SueZhaZa wrote:Thanks!![]()
btw, i just discover on the ~Scan code..
can someone elaborate more on this?
The tilde (~) in front of it is a logical Not operator. These are described in the section of the Reference Guide titled Logical Operators in TM1 Rules.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.
SCAN(substring, string)
...
Example
SCAN('scribe', 'described') returns 3.
I haven't read through the whole of Steve's code to see exactly what it's doing but when he says:Operator Meaning Example
~ (tilde) NOT ~(Value1 > 5) Equivalent to (Value1 <= 5)
Code: Select all
If ( ~Scan ( ‘Null’ , sParent | sChild ) >0);
TI scans the combined expression sParent | sChild for the word 'Null'. If it finds it, the result will be greater than 0.
However the block of code is only executed if that is NOT true (that is, if you don't find the word Null in there) because of the ~ operator.
Actually you could probably also express this as:
Code: Select all
If ( Scan ( ‘Null’ , sParent | sChild ) =0);
Edit: Oh dear, I missed the close by moments. No matter, no harm in letting the post stand.

"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.
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
Thanks Alan!
Great Help!!!
btw.. just wondering, what if the 'NULL' (a string NULL) is a real null value (real blank)... scan doesnt work anymore right?
Great Help!!!




btw.. just wondering, what if the 'NULL' (a string NULL) is a real null value (real blank)... scan doesnt work anymore right?
vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
-
- 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: Need Help
It's worth bearing in mind that you can't actually get a "null" in a feed to TM1. Null is essentially a relational database concept. Null isn't an empty string (for text fields) and nor is it zero (for numeric fields) it is, in fact, a void; an undefined value. In SQL, Null has been described as something which "sucks the life out of" a value since when you perform any operation against a null field you get... null.SueZhaZa wrote:Thanks Alan!
Great Help!!!![]()
![]()
![]()
![]()
btw.. just wondering, what if the 'NULL' (a string NULL) is a real null value (real blank)... scan doesnt work anymore right?
However you can't get real, genuine nulls in an interface to T.I. because it accepts only two data types; strings and numerics. A null which is being fed to a string variable must be reinterpreted as an empty string, and a null which is being fed to a numeric variable must be reinterpreted as a zero.
However your feed is one step removed from a direct feed from the database anyway; it's a .csv, which is by definition pure text. Any nulls need to be converted by the database before it can write such a file. The conversion of a null will typically be to an "empty" field; one where there is nothing between two of the commas. (Not always, of course; in your case the database appears to be converting it to the explicit word "NULL" so that you can identify it as such.)
Although a .csv file is completely text some of the columns, ones which contain text which is in numeric format, can be fed to numeric variables in TI. If a row contains a zero length string, meaning that the file looks something like this, say:
Code: Select all
FirstStringField,NumericField,SecondStringField,ThirdStringField
Description,100,Line1,MoreText
AnotherDesc,,Line2,NumericEmptyHere
ThirdDesc,500,,SecondStringEmptyHere
OneLastDesc,970,Line4,YetMoreTextAgain
(As an aside, Line2 will be OK if the numeric field is empty as shown above; if it contains text there won't be a conversion to 0, it will instead throw an error.)
However your question is closer to the situation on line 3, where the SecondStringField value is empty. In such a case, yes, the value that comes through into the TI variable will be the equivalent of '' and you're quite correct that such a value can't be used in a Scan.
"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.
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
actually the .csv files is for testing purposes..
i just discover that the real procedure is DIRECTLY from SQL server... with a void, null value (neither string or numeric and yeah as what u explained earlier...)..
from what i understand the SQL server will show 'NULL' for void when doing query in SQL...
and once converted to .csv it will convert from void null to text 'NULL'.
if i'm to test the .csv, by leaving the cell blank, would it be similar to void?


i just discover that the real procedure is DIRECTLY from SQL server... with a void, null value (neither string or numeric and yeah as what u explained earlier...)..
from what i understand the SQL server will show 'NULL' for void when doing query in SQL...
and once converted to .csv it will convert from void null to text 'NULL'.
if i'm to test the .csv, by leaving the cell blank, would it be similar to void?






vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe
-
- 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: Need Help
Not exactly. By default when you run a query in SQL Server Management Studio, then any null fields will display with the word "Null". Similarly if you run the query to either Text or to a File (probably the source of your original .csv) then again the word NULL will be displayed, as you've found. There may be a way to override this (other than the obvious one of embedding a Convert command in the original SQL) but I don't know it because to be honest I've never wanted it any other way.SueZhaZa wrote:actually the .csv files is for testing purposes..![]()
i just discover that the real procedure is DIRECTLY from SQL server... with a void, null value (neither string or numeric and yeah as what u explained earlier...)..
from what i understand the SQL server will show 'NULL' for void when doing query in SQL...
and once converted to .csv it will convert from void null to text 'NULL'.
However when you use an ODBC connection to pull the same query into TI, the process is smart enough to convert nulls to zero length strings or zero, as the case may be:
"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.
-
- 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: Need Help
Oh, and for the sake of penance for omitting the "obvious" option above (and also because I'm feeling bored at the moment) I'll add that it's the Coalesce function that you can use to generate the output from SQL Server without the word Null. For instance, the code mentioned in the previous post will return zeros and empty strings straight out of SQL server, not just at the TI interface, if coded like this:Alan Kirk wrote:By default when you run a query in SQL Server Management Studio, then any null fields will display with the word "Null". Similarly if you run the query to either Text or to a File (probably the source of your original .csv) then again the word NULL will be displayed, as you've found. There may be a way to override this (other than the obvious one of embedding a Convert command in the original SQL) but I don't know it because to be honest I've never wanted it any other way.
Code: Select all
SELECT TOP 1000 COALESCE([Text1],'')
,COALESCE([Value1],0)
,COALESCE([Text2],'')
FROM [Test].[dbo].[Table_1]
"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.
- SueZhaZa
- Posts: 17
- Joined: Tue Feb 28, 2012 2:58 am
- OLAP Product: TM1
- Version: 9.2.5
- Excel Version: 2003
- Location: Malaysia
- Contact:
Re: Need Help
Hi Alan,
Appreciate your post replies!
the thing is now the SQL is none of my business... (haha! its from the client side)
i tried in order to eliminate any nulls.. so far so good.. as i blank the cell in the csv for testing purposes...
what say you?
would it apply the same to NULL values?

Appreciate your post replies!
the thing is now the SQL is none of my business... (haha! its from the client side)
i tried
Code: Select all
If ( ~LONG (sChild) =0);
what say you?
would it apply the same to NULL values?





vain, childish, talkative, dreamy, lazy, friendly, warm, lively, busy, complicated, bubbly, moody, kind, cruel, playful, irritating, forgetful, ironic, loud, open, protective, supportive, freak, rebellious, assertive - unique. like everyone else .exe