Hi,
I want to retrieve all the elements in Dimension to use it for CellputS function
please help me in the same
Thanks
Amit
Want to retrieve all element in Dimension
-
- Posts: 21
- Joined: Tue Jan 17, 2012 6:22 am
- OLAP Product: TM1
- Version: 9.5.2
- Excel Version: Excel 2007
-
- MVP
- Posts: 3701
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Want to retrieve all element in Dimension
Dear Amit,
On face value this is a pretty simple requirement that just requires a while loop to iterate through the dimension. You might want to elaborate on WHY or WHAT you actually need to do as you have mentioned CellPutS as opposed to AttrPutS which I assume to mean that there are additional dimension coordinates that you also need to know - are these additional coordinates fixed values or variable? Depending on the situation the loop might go on the prolog or within the data tab, ... or you might not need a loop at all and you could just have a simple CellPutS by itself on the data tab. Unless you explain what you actually need to do and give some more thought to your question it's not possible to help any further.
Then you need to do something useful within the While loop such as
CellPutS('your string value', 'yourCube', sDim1, sDim2, .... sDimN);
... where you would substitute the sElName variable for one of the sDim references
On face value this is a pretty simple requirement that just requires a while loop to iterate through the dimension. You might want to elaborate on WHY or WHAT you actually need to do as you have mentioned CellPutS as opposed to AttrPutS which I assume to mean that there are additional dimension coordinates that you also need to know - are these additional coordinates fixed values or variable? Depending on the situation the loop might go on the prolog or within the data tab, ... or you might not need a loop at all and you could just have a simple CellPutS by itself on the data tab. Unless you explain what you actually need to do and give some more thought to your question it's not possible to help any further.
Code: Select all
# loop through dimension (courtesy of Vizier code snippet)
sDimName = 'yourDim';
nCounter = 1;
nMaximum = DimSiz(sDimName);
WHILE(nCounter <= nMaximum);
sElName = DimNm(sDimName, nCounter);
nCounter = nCounter + 1;
END;
CellPutS('your string value', 'yourCube', sDim1, sDim2, .... sDimN);
... where you would substitute the sElName variable for one of the sDim references
-
- Site Admin
- Posts: 1458
- Joined: Wed May 28, 2008 9:09 am
Re: Want to retrieve all element in Dimension
Why not just set the view or subset as the data source? Then the looping is done for you.
- 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: Want to retrieve all element in Dimension
A good point David but in some cases models are setup to avoid dynamic subsets. For this to work you would need to use one for dimensions that change often. If dynamic subsets are not a problem in your model then I agree. If they are then Lotsarams solution is a good alternative.
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
-
- Site Admin
- Posts: 1458
- Joined: Wed May 28, 2008 9:09 am
Re: Want to retrieve all element in Dimension
Indeed...
But I didn't mention dynamic subsets. It's often easier to use the All subset and skip the elements you don't want.
But I didn't mention dynamic subsets. It's often easier to use the All subset and skip the elements you don't want.
-
- MVP
- Posts: 3701
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Want to retrieve all element in Dimension
I agree, and I believe I already made reference to this.David Usherwood wrote:Why not just set the view or subset as the data source? Then the looping is done for you.
But it depends on what the OP actually needs to do, and unless he provides that information no point having any debate about the x^n various methods of solving the problem.lotsaram wrote: ... or you might not need a loop at all and you could just have a simple CellPutS by itself on the data tab.
- 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: Want to retrieve all element in Dimension
For me it's like using a crane to lift a cardboard box. While it will work it's over kill. David's solution is the simple soultion, Lotsaram yours is the crane.
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