Dimension Element Delete NOT Working
-
- Posts: 40
- Joined: Wed Feb 06, 2013 9:53 am
- OLAP Product: cognos tm1
- Version: 10.1.1
- Excel Version: 2007
- Location: Bangalore,India
Dimension Element Delete NOT Working
Hi,
I have Dimension 2h_District.
2h_District has a TEXT Attribute , Company.
Now, I want to delete all the elements in 2h_District where Company in NULL.
Eg.
District Company
N201 IN10
N202 (Blank)
I wrote a Code in TI Metadata.
If
(
ATTRS('2h_District',vDistrict,'Company') @=' '
);
DimensionElementDelete('2h_District',vDistrict);
itemskip;
ENDIF;
Result should be:-
N202 should be deleted from 2h_District
But, this code is NOT working.
Can anyone help me please?
Regards,
Roy.
I have Dimension 2h_District.
2h_District has a TEXT Attribute , Company.
Now, I want to delete all the elements in 2h_District where Company in NULL.
Eg.
District Company
N201 IN10
N202 (Blank)
I wrote a Code in TI Metadata.
If
(
ATTRS('2h_District',vDistrict,'Company') @=' '
);
DimensionElementDelete('2h_District',vDistrict);
itemskip;
ENDIF;
Result should be:-
N202 should be deleted from 2h_District
But, this code is NOT working.
Can anyone help me please?
Regards,
Roy.
-
- Posts: 48
- Joined: Thu Apr 11, 2013 7:47 am
- OLAP Product: Cognos TM1
- Version: 10.2
- Excel Version: 2010
Re: Dimension Element Delete NOT Working
Hi Roy,
It seems you have used ATTRS widely in the project.
ATTRS is good function of TM1, but still very dangerous if used without caution.
It seems you have used ATTRS widely in the project.
ATTRS is good function of TM1, but still very dangerous if used without caution.
-
- MVP
- Posts: 1828
- 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: Dimension Element Delete NOT Working
Roy,
Just stick an extra line in your TI process to do an asciioutput of whatever the AttrS does return and then you will see why it is not matching your conditions.
I would say that this expands to every function within any code language... if you don't use functions correctly there will be issues.
This seems a normal way to use it though.
Just stick an extra line in your TI process to do an asciioutput of whatever the AttrS does return and then you will see why it is not matching your conditions.
TM1andTM1,Tm1andTm1 wrote:Hi Roy,
It seems you have used ATTRS widely in the project.
ATTRS is good function of TM1, but still very dangerous if used without caution.
I would say that this expands to every function within any code language... if you don't use functions correctly there will be issues.
This seems a normal way to use it though.
Declan Rodger
-
- MVP
- Posts: 3702
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Dimension Element Delete NOT Working
What exactly do you mean by that? Please explain how ATTRS can be "dangerous".Tm1andTm1 wrote:ATTRS is good function of TM1, but still very dangerous if used without caution.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
-
- MVP
- Posts: 3230
- 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: Dimension Element Delete NOT Working
Attribute values could be empty for an alias (but that would not be an issue for text attributes, in that case it's empty and you (should) know it).lotsaram wrote:What exactly do you mean by that? Please explain how ATTRS can be "dangerous".Tm1andTm1 wrote:ATTRS is good function of TM1, but still very dangerous if used without caution.
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
-
- Posts: 48
- Joined: Thu Apr 11, 2013 7:47 am
- OLAP Product: Cognos TM1
- Version: 10.2
- Excel Version: 2010
Re: Dimension Element Delete NOT Working
lotsaram wrote:What exactly do you mean by that? Please explain how ATTRS can be "dangerous".Tm1andTm1 wrote:ATTRS is good function of TM1, but still very dangerous if used without caution.
Lotsaram
It is difficult to put in words,
Well..... it would be your experience which can give you the answer of this question.....
- 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: Dimension Element Delete NOT Working
Think you are missing an ELSE statement, try;roy2087 wrote: If (ATTRS('2h_District',vDistrict,'Company') @=' ' );
DimensionElementDelete('2h_District',vDistrict);
itemskip;
ENDIF;
Code: Select all
If (ATTRS('2h_District',vDistrict,'Company') @=' ' );
DimensionElementDelete('2h_District',vDistrict);
ELSE;
itemskip;
ENDIF;
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
-
- Community Contributor
- Posts: 110
- Joined: Thu Aug 26, 2010 7:41 am
- OLAP Product: TM1, PA
- Version: PAL 2.0.8
- Excel Version: 2016
- Location: North West England
Re: Dimension Element Delete NOT Working
Maybe others can correct me If I am wrong but I know TM1 is not Space sensitive when it comes to element names etc however it can be for Data.
As such you might want to search for '' instead of ' ' in ATTRS or always search for '' and wrap your attrs with a TRIM function.
Hope this helps.
As such you might want to search for '' instead of ' ' in ATTRS or always search for '' and wrap your attrs with a TRIM function.
Hope this helps.
Always Open to Opportunities
-
- MVP
- Posts: 1828
- 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: Dimension Element Delete NOT Working
Steve Vincent wrote: Think you are missing an ELSE statement, try;
Code: Select all
If (ATTRS('2h_District',vDistrict,'Company') @=' ' ); DimensionElementDelete('2h_District',vDistrict); ELSE; itemskip; ENDIF;
Not sure without seeing what else is in the code but I had assumed it was meant to be along the lines of:
If the District doesn't have a company attribute - Delete the Element AND skip the rest of the code on that tab...
otherwise - continue with the rest of the code for the Elements that still exist.
Declan Rodger
-
- MVP
- Posts: 3702
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Dimension Element Delete NOT Working
No really in all seriousness. In your (I'm sure enormous) experience please do elucidate on how ATTRS can be a dangerous function and how do you suggest caution in its use versus wild abandon?Tm1andTm1 wrote:ATTRS is good function of TM1, but still very dangerous if used without caution.
....
It is difficult to put in words,
Well..... it would be your experience which can give you the answer of this question.....
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
- jim wood
- Site Admin
- Posts: 3958
- Joined: Wed May 14, 2008 1:51 pm
- OLAP Product: TM1
- Version: PA 2.0.7
- Excel Version: Office 365
- Location: 37 East 18th Street New York
- Contact:
Re: Dimension Element Delete NOT Working
Erm, I'm a little stumped here. Surely CellPutS is more dangerous as not only can you update data cells you can also achieve the same as a ATTRS when sending data to control cubes?Tm1andTm1 wrote:ATTRS is good function of TM1, but still very dangerous if used without caution.
Struggling through the quagmire of life to reach the other side of who knows where.
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
Shop at Amazon
Jimbo PC Builds on YouTube
OS: Mac OS 11 PA Version: 2.0.7
-
- MVP
- Posts: 733
- Joined: Wed May 14, 2008 11:06 pm
Re: Dimension Element Delete NOT Working
Although it is not the case with all TI functions, it is definitely the case with ATTRS that it is not a good coding practice in TI to put the function directly within the condition of an IF statement. Try these two examples in a test process and you will see that in the case of the first example, no error is thrown and, in fact, the 'false' clause is executed. IMHO this creates unacceptable risk:roy2087 wrote:I wrote a Code in TI Metadata.
If
(
ATTRS('2h_District',vDistrict,'Company') @=' '
);
DimensionElementDelete('2h_District',vDistrict);
itemskip;
ENDIF;
Code: Select all
nResult = 1;
# no error thrown on next line even though dimension does not exist - condition just evaluates to FALSE
IF ( ATTRS ( 'Not_Exists', 'Me_Neither', 'Foo' ) @= 'Bar' );
nResult = 2;
ELSE;
nResult = 3;
ENDIF;
ItemReject ( 'Answer is: ' | NumberToString ( nResult ) );
Code: Select all
nResult = 1;
# error occurs on next line because no such dimension exists
sAttritbuteValue = ATTRS ( 'Not_Exists', 'Me_Neither', 'Foo' );
# this logic is never evaluated as process has aborted
IF ( sAttritbuteValue @= 'Bar' );
nResult = 2;
ELSE;
nResult = 3;
ENDIF;
ItemReject ( 'Answer is: ' | NumberToString ( nResult ) );
Robin Mackenzie
-
- Posts: 40
- Joined: Wed Feb 06, 2013 9:53 am
- OLAP Product: cognos tm1
- Version: 10.1.1
- Excel Version: 2007
- Location: Bangalore,India
Re: Dimension Element Delete NOT Working
Hi,
I have made some changes in the Data Source section.
Earlier, I was using "Cube View" as a Data Source,
but now I am using "Dimension Sub" as a Data Source.
In the Dimension(2h_District), I have made a subset which has only Leaf Level elements.
Then , I am using this following code in the Metadata Section..
**************************************************************
If
(
ATTRS('2h_District',vDistrict,'Company') @=' '
);
DimensionElementDelete('2h_District',vDistrict);
itemskip;
ENDIF;
*************************************************************
Phew..! It worked.
Did'nt know changing the Data Source would make such as a difference.
Thanks everyone!
Roy....
I have made some changes in the Data Source section.
Earlier, I was using "Cube View" as a Data Source,
but now I am using "Dimension Sub" as a Data Source.
In the Dimension(2h_District), I have made a subset which has only Leaf Level elements.
Then , I am using this following code in the Metadata Section..
**************************************************************
If
(
ATTRS('2h_District',vDistrict,'Company') @=' '
);
DimensionElementDelete('2h_District',vDistrict);
itemskip;
ENDIF;
*************************************************************
Phew..! It worked.
Did'nt know changing the Data Source would make such as a difference.
Thanks everyone!
Roy....
-
- Posts: 48
- Joined: Thu Apr 11, 2013 7:47 am
- OLAP Product: Cognos TM1
- Version: 10.2
- Excel Version: 2010
Re: Dimension Element Delete NOT Working
Hi roy2087,
Have you got the solution you require......? If not, please let me know
Have you got the solution you require......? If not, please let me know
-
- Posts: 40
- Joined: Wed Feb 06, 2013 9:53 am
- OLAP Product: cognos tm1
- Version: 10.1.1
- Excel Version: 2007
- Location: Bangalore,India
Re: Dimension Element Delete NOT Working
Yes, I have got the solution.