Hi there,
If I need to recreate a dimension with a brand new set of data, what I am doing is to use DimensionDeleteAllElements to truncate the dimension at first.
When I put this command at the first line in one TI followed with codes to fill the dimension, the dimension is always empty.
However, instead of directly using this command, I put it in another process to be called, then it works.
So, what do I need to be done in order to use DimensionDeleteAllElements directly?
Thank you.
To use DimensionDeleteAllElements
-
- MVP
- Posts: 1815
- 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: To use DimensionDeleteAllElements
When you say "first line" do you mean of the prolog or metadata tabs? If it's in the metadata it will delete the whole dimension over and over again as each record is processed.nayitian wrote:Hi there,
If I need to recreate a dimension with a brand new set of data, what I am doing is to use DimensionDeleteAllElements to truncate the dimension at first.
When I put this command at the first line in one TI followed with codes to fill the dimension, the dimension is always empty.
However, instead of directly using this command, I put it in another process to be called, then it works.
So, what do I need to be done in order to use DimensionDeleteAllElements directly?
Thank you.
If it is in the prolog can you please post the code for the whole TI as that shouldn't happen.
Declan Rodger
-
- MVP
- Posts: 3117
- Joined: Mon Dec 29, 2008 6:26 pm
- OLAP Product: TM1, Jedox
- Version: PAL 2.0.9.18
- Excel Version: Microsoft 365
- Location: Brussels, Belgium
- Contact:
Re: To use DimensionDeleteAllElements
In addition to what Declan said, even in the Prolog, it can be that nothing happens.
For example, run this if you have a dimension called 'test':
Reversing the 2 statements makes it work but it's not intuitive to users and developers with not that much experience under their belt.
For example, run this if you have a dimension called 'test':
Code: Select all
DimensionSortOrder( 'test', 'ByName', 'Descending', 'ByLevel', 'Ascending');
DimensionDeleteAllElements( 'test' );
Best regards,
Wim Gielis
IBM Champion 2024
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
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
-
- MVP
- Posts: 1815
- 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: To use DimensionDeleteAllElements
Wim Gielis wrote:In addition to what Declan said, even in the Prolog, it can be that nothing happens.
For example, run this if you have a dimension called 'test':
Reversing the 2 statements makes it work but it's not intuitive to users and developers with not that much experience under their belt.Code: Select all
DimensionSortOrder( 'test', 'ByName', 'Descending', 'ByLevel', 'Ascending'); DimensionDeleteAllElements( 'test' );
Any metadata change to a dimension (such as dimensionelementinsert or dimensionsortorder) creates a copy of the dimension which is committed back when the tab completes; I have nothing from IBM that confirms this but I have always assumed that this is why a DimensionDeleteAllElements AFTER a metadata change doesn't work, since DimensionDeleteAllElements() works on the original dimension that is then overwritten anyway.
But since OP said first line I assume this isn't the issue and it sounds like the OP is getting the opposite effect of that issue i.e an empty dimension (suggesting that DimensionDeleteAllElements has done something.)
Declan Rodger
-
- Regular Participant
- Posts: 424
- Joined: Sat Mar 10, 2012 1:03 pm
- OLAP Product: IBM TM1, Planning Analytics, P
- Version: PAW 2.0.8
- Excel Version: 2019
Re: To use DimensionDeleteAllElements
I am sorry Declan ,Didn't understand fully what you are trying to explain here.Could you give please give an example.Thanksdeclanr wrote:Wim Gielis wrote:In addition to what Declan said, even in the Prolog, it can be that nothing happens.
For example, run this if you have a dimension called 'test':
Reversing the 2 statements makes it work but it's not intuitive to users and developers with not that much experience under their belt.Code: Select all
DimensionSortOrder( 'test', 'ByName', 'Descending', 'ByLevel', 'Ascending'); DimensionDeleteAllElements( 'test' );
Any metadata change to a dimension (such as dimensionelementinsert or dimensionsortorder) creates a copy of the dimension which is committed back when the tab completes; I have nothing from IBM that confirms this but I have always assumed that this is why a DimensionDeleteAllElements AFTER a metadata change doesn't work, since DimensionDeleteAllElements() works on the original dimension that is then overwritten anyway.
But since OP said first line I assume this isn't the issue and it sounds like the OP is getting the opposite effect of that issue i.e an empty dimension (suggesting that DimensionDeleteAllElements has done something.)
"You Never Fail Until You Stop Trying......"
-
- MVP
- Posts: 1815
- 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: To use DimensionDeleteAllElements
BariAbdul,
Wim already gave example code to prove the point (it is in fact enclosed in the quoted reply you posted.)
Try using that. You can also try using that but replacing the DimensionSortOrder with another metadata function.
Wim already gave example code to prove the point (it is in fact enclosed in the quoted reply you posted.)
Try using that. You can also try using that but replacing the DimensionSortOrder with another metadata function.
Declan Rodger