Page 1 of 1

Lookup Dimension

Posted: Thu Mar 25, 2010 2:17 pm
by ThomasCS
Hey,

Trying to find a solution to this problem.

I have a cube with is build like this:

The rows are made up by an list of Items.
There is a colomn called Profile Number.
There are several other dimensions (but those are not relevant)

The user can give in a number next to each Item. There is no logic between the number and item 1

Ex:

Code: Select all

Items - Profile Number
-------------------
Item 1 - 1003
Item 2 - 1012
Item 3 - 1005
Item 4 - 1024
....
Now I want to create a TI process in which a .cma file is read.
One column in the file contains the Profile Number, but not the Item name. So I have to match profile number with the corresponding Item name.
Is there a way to loop though each cell of the Profile Number column to find the Profile Number and return the name of the Item from the dimension?

ex. You have 1012 and it should return Item 2.

Many Thanks
Thomas

Re: Lookup Dimension

Posted: Thu Mar 25, 2010 2:28 pm
by kpk
Hello,

Do you have an item dimension?
If yes then you can create an alias to store the profile number and can use the DimensionElementPrincipalName function instead of looping.
For looping you can use the WHILE function but it can be a much slower solution.

Regards,
Peter

DimensionElementPrincipalName
This is a TM1 TurboIntegrator function, valid only in TurboIntegrator processes.
This function returns the principal name of an element or element alias.
TurboIntegrator must use principal element names when updating dimensions; element aliases
cannot be used. This function is therefore useful for determining principal element names while
attempting to update a dimension when only element aliases are available to the TurboIntegrator
process.
Syntax
DimensionElementPrincipalName( DimName, ElName )

Re: Lookup Dimension

Posted: Thu Mar 25, 2010 2:32 pm
by Steve Rowe
Something like this

#From your source file your profile number goes into varProfileNumber

In the Prolog

maxItem=Dimsiz('DimNameItem');

In the data tab a while loop

ixItem=1;
While (ixItem<=maxItem);
#The use of dimnm in the CelLGetN allows us to loop through the dimNameItem dimension.
If (varProfileNumber = CellGetN ( 'Your Cube', ,dim refs, dimNm('dimNameItem', ixItem),.......);
#You've found the match so do your work.

#Force the loop to exit
ixItem=maxItem;
EndIf;
ixItem=ixItem+1;
End;

Things to watch out for
Take care while coding the while statement, if you don't get the counters right you'll have an infinte loop and you'll have to kill the server.
The data type of varProfileNumber is assumed to be a number, use the @= test if its a string and Str if you need to convert the profile entered by the user.
Obviously not even close to a full TI script but hopefully enough to start you off.
Cheers

Re: Lookup Dimension

Posted: Thu Mar 25, 2010 2:57 pm
by ThomasCS
@kpk: Thanks for the help, but I can't use attributes in this case. Like I said there is no logic between number and item, and because the other non relevant dimensions it's possible the profile number is different for a item depending on the selection of the other dimensions.

@Steve Rowe: thanks, I think your solution is the one i was looking for.

greetings
Thomas