Page 1 of 1

Using ATTRS in TI

Posted: Thu May 13, 2010 7:40 am
by appleglaze28
I was wondering, if anybody can help me out with this. I'm trying to do a TI where data from an old cube with 3 dimension and transfer it to a new dimension with 4 dimension. Like on a previous post related to this...rather than creating rules, I want to use to TI so I can transfer the data and delete the old cube.

How do you declare the attribute here since it doesn't allow the use of dimension names near the syntax of ATTRS.

I know i need to declare the "model" dimension as a static parameter here but I'm not sure yet cause I can't get pass the error I'm having right now. How different are syntax both useable in Rules & TI to be written.

DATA:

Code: Select all

i = DIMSIZ('product');
while(i>1);
  vprod = DIMNM('product', i);
IF (ATTRS('product', 'vprod', 'model')=!model);
              CellGetS('Sales', !month, !product, !value_sales);
              CellGetN('Sales', !month, !product, !value_sales);
              CellPutS('SalesModel',!model, !month, !product, !value_sales);
              CellPutN('SalesModel',!model, !month, !product, !value_sales);
  i = i - 1;
end;
ATTRS in TI.PNG
ATTRS in TI.PNG (118.08 KiB) Viewed 3611 times

Re: Using ATTRS in TI

Posted: Thu May 13, 2010 9:47 am
by olapuser
you did not put the closing if (endif) and wrong logical expression

Code: Select all

DimName='product';
NoOfElements=DimSiz(DimName);
index = 1;
WHILE( index<=NoOfElements );
	ElName=DIMNM(DimName, index);
	IF (ATTRS('product', 'vprod', 'model')@=model);
	    CellGetS('Sales', !month, !product, !value_sales);
	    CellGetN('Sales', !month, !product, !value_sales);
	    CellPutS('SalesModel',!model, !month, !product, !value_sales);
    	CellPutN('SalesModel',!model, !month, !product, !value_sales);
    endif;
	index = index+1;
END;

Re: Using ATTRS in TI

Posted: Fri May 14, 2010 12:48 am
by Andy Key
Just a couple of suggestions:

You should be using a cube view on the old cube as a data source for the TI, so there is no need for any looping.
Once you have this, you will be given variable names that you must replace all your !<dimname> references with.
You don't need quotes around the second parameter to the ATTRS as it is a variable not a fixed string.
You should be using the result of the ATTRS as the value for the Model dimension.
You should do a test of the data type of the cell you are getting before you get it so that you only perform the CellGetS and CellPutS or the CellGetN and CellPutN.
You need to assign the CellGetS/N to a variable.
You need to use this variable as the first parameter of the CellPutS/N.

Apart from that, I would say you are pretty close...