Page 1 of 1

dimix use

Posted: Sun Aug 16, 2015 5:47 am
by Moh
Hello Sir,I am confused about dimix.The reference guide says if( dimix(dimensionname,elementname)=1) means in TI if element exists and the rules guide says in chap10 ---> IF(DIMIX(’Date’, !Date)=1) means This rules say "if the current date is the first date in the Date dimension, thenQuantity in Stock - Kgs is 0; otherwise Quantity in Stock - Kgs is equal toyesterday's Remaining value from the Depletion cube for the immediatelyprevious DaysOld batch.Is there different usage for dimix in rules and TI and what is the difference.thanks for clarifying my doubt.The complete rules example----> [’Quantity in Stock - Kgs’]= N: IF(DIMIX(’Date’, !Date)=1,
0, DB(’Depletion’,!FishType,DIMNM(’Date’, DIMIX(’Date’, !Date)-1),
DIMNM(’DaysOld’,DIMIX(’DaysOld’, !DaysOld) -1),’Remaining’));

Re: dimix use

Posted: Sun Aug 16, 2015 8:08 am
by Martin Ryan
I can see two possible angles to your question so hopefully one of the two answers is what you're after.

DIMIX of zero means that an element is not in the dimension. E.g. dimix('DaysOfTheWeek', 'Tomato'); is likely to return zero because 'Tomato' isn't an element in the DaysOfTheWeek dimension. So the typical use of this is

Code: Select all

if(dimix('MyDim', Elem)<>0); do something; endif;
or

Code: Select all

if(dimix('MyDim', Elem)=0); do something else; endif;
However from the second half of your question I think you're talking about finding out what the next element in the dimension is.

Code: Select all

['Tomorrows']=dbrw('Cube', dimnm('Day', dimix('Day', !Day)+1), !FishType);
Likewise this returns the previous element in the dimension.

Code: Select all

['Yesterdays']=dbrw('Cube', dimnm('Day', dimix('Day', !Day)-1), !FishType);
Personally I'm not a fan of this approach because it means two function calls, and if your dimension in not in the order you think it is, then you'll get unpredictable numbers. I prefer setting up "Next" and "Prev" attributes, then using them like so

Code: Select all

['Tomorrows']=dbrw('Cube', attrs('Day', !Day, 'Next'), !FishType);
['Yesterdays']=dbrw('Cube', attrs('Day', !Day, 'Prev'), !FishType);

Re: dimix use

Posted: Sun Aug 16, 2015 12:14 pm
by Moh
Thank you.if(dimix('MyDim', Elem)=0) returns 0 or 1 depending on element exists in the dimension.in the rule it says---->IF(DIMIX(’Date’, !Date)=1) means This rules say "if the current date is the first date in the Date dimension,here value of 1 is assigned if the current date is the first date in the Date dimension.this usage confusing me.once again,thanks for clarifying my doubt.

Re: dimix use

Posted: Sun Aug 16, 2015 1:16 pm
by declanr
Moh wrote:Thank you.if(dimix('MyDim', Elem)=0) returns 0 or 1 depending on element exists in the dimension.in the rule it says---->IF(DIMIX(’Date’, !Date)=1) means This rules say "if the current date is the first date in the Date dimension,here value of 1 is assigned if the current date is the first date in the Date dimension.this usage confusing me.once again,thanks for clarifying my doubt.
Dimix is not a boolean yes/no function as to whether an element exists or not; a 0 response does indeed indicate the the element specified does not exist in the dimension - but if the element does exist it will return the index of the element within the dimension (i.e. 1 if the element is the first in the dimension or 999999 if it is the 999999th element in the dimension.)

Re: dimix use

Posted: Fri Aug 21, 2015 8:55 am
by Moh
thank you all.