Rule - count
-
- Posts: 11
- Joined: Mon Nov 09, 2009 2:49 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2007
Rule - count
Hi Guys,
I’m new to TM1, so please excuse me if my question comes across very straight forward. One of the measures I require is a count of stores, Would I create this in the rules? I need to be able to count the number of IDs (lower leaf element) in one of the dimensions.
Any help would be appreciated
Regards
Dave
I’m new to TM1, so please excuse me if my question comes across very straight forward. One of the measures I require is a count of stores, Would I create this in the rules? I need to be able to count the number of IDs (lower leaf element) in one of the dimensions.
Any help would be appreciated
Regards
Dave
-
- MVP
- Posts: 214
- Joined: Tue Nov 11, 2008 11:57 pm
- OLAP Product: TM1, CX
- Version: TM1 7x 8x 9x 10x CX 9.5 10.1
- Excel Version: XP 2003 2007 2010
- Location: Hungary
Re: Rule - count
Hello,
Try the ELCOMPN rule function.
Regards,
Peter
ELCOMPN returns the number of components in a specified element. If the element argument is not a consolidated element, the function returns 0.
Syntax
ELCOMPN(dimension, element)
Arguments
dimension A valid dimension name.
element The name of a consolidated element within the dimension. This argument must be the name of a valid element defined in the dimension. It cannot be a user-defined consolidation.
Example
ELCOMPN(‘Region’,’Scandanavia’)
In the Region dimension, the element Scandanavia is a consolidation of three elements. The example returns 3.
Try the ELCOMPN rule function.
Regards,
Peter
ELCOMPN returns the number of components in a specified element. If the element argument is not a consolidated element, the function returns 0.
Syntax
ELCOMPN(dimension, element)
Arguments
dimension A valid dimension name.
element The name of a consolidated element within the dimension. This argument must be the name of a valid element defined in the dimension. It cannot be a user-defined consolidation.
Example
ELCOMPN(‘Region’,’Scandanavia’)
In the Region dimension, the element Scandanavia is a consolidation of three elements. The example returns 3.
Best Regards,
Peter
Peter
-
- Posts: 11
- Joined: Mon Nov 09, 2009 2:49 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2007
Re: Rule - count
Hi,
Thanks for your response. I've applied the fucntion ELCOMPN to the rules, however it takes a very long time to save the rule and open the cube now.
Any suggestions why this might be?
Thanks for your response. I've applied the fucntion ELCOMPN to the rules, however it takes a very long time to save the rule and open the cube now.
Any suggestions why this might be?
- Steve Rowe
- Site Admin
- Posts: 2456
- Joined: Wed May 14, 2008 4:25 pm
- OLAP Product: TM1
- Version: TM1 v6,v7,v8,v9,v10,v11+PAW
- Excel Version: Nearly all of them
Re: Rule - count
Dave,
You'll need to post your rules for us to help plus details of the cube and the dimension sizes. It's normal for the introduction of rules and feeders to slow things down. If you have the scope of the rule too wide then this can be dramtic.
From what you say you may be better off calculating the number of stores and storing it in a lookup cube. Functions that work off couting pieces of structure can be slow and you want to do them as few times as possible.
I'm going to guess what you need.
You have a dimension store, Level 0 is Store and Level 1 is region and level 2 is Country.
You want to know the number of stores at the region level.
So
Create a look up cube wit the dimensions Store and Store Properties
The Store Properties dimension has Store Count as an element
Write a rule in the look up cube for Store Count, something like this, syntax is not complete
['Store Count']=N:If ( Ellev('Store', !Store)=1, ElcompN ( blah blah blah),stet);
This calculates the result we need in the lookup cube.
Reference this result in the main cube whenever you need the Store Count.
Since TM1 caches numeric results the store count is only ever calculated once.
(This is the reason we don't use an attribute cube. We can only write string rules in an attribute cube and since TM1 doesn't cache the result of string calcs we are back to square one with many thousands of calcs where only 1 is required)
Anyway HTH
You'll need to post your rules for us to help plus details of the cube and the dimension sizes. It's normal for the introduction of rules and feeders to slow things down. If you have the scope of the rule too wide then this can be dramtic.
From what you say you may be better off calculating the number of stores and storing it in a lookup cube. Functions that work off couting pieces of structure can be slow and you want to do them as few times as possible.
I'm going to guess what you need.
You have a dimension store, Level 0 is Store and Level 1 is region and level 2 is Country.
You want to know the number of stores at the region level.
So
Create a look up cube wit the dimensions Store and Store Properties
The Store Properties dimension has Store Count as an element
Write a rule in the look up cube for Store Count, something like this, syntax is not complete
['Store Count']=N:If ( Ellev('Store', !Store)=1, ElcompN ( blah blah blah),stet);
This calculates the result we need in the lookup cube.
Reference this result in the main cube whenever you need the Store Count.
Since TM1 caches numeric results the store count is only ever calculated once.
(This is the reason we don't use an attribute cube. We can only write string rules in an attribute cube and since TM1 doesn't cache the result of string calcs we are back to square one with many thousands of calcs where only 1 is required)
Anyway HTH
Technical Director
www.infocat.co.uk
www.infocat.co.uk
-
- Posts: 11
- Joined: Mon Nov 09, 2009 2:49 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2007
Re: Rule - count
Thanks for your help. Please find attached details of my dimensions and sizing.
I need to be able to count the number of stores at the leaf element with the NISA Account Group dimension. The structure looks like this
'All NISA Account Group'
'NISA Account Number'
'Account Group'
'Store'
I'd like to be able to report on the number of stores in a 4 week period or 12 week period selling a particular product
Example attached
I need to be able to count the number of stores at the leaf element with the NISA Account Group dimension. The structure looks like this
'All NISA Account Group'
'NISA Account Number'
'Account Group'
'Store'
I'd like to be able to report on the number of stores in a 4 week period or 12 week period selling a particular product
Example attached
- Attachments
-
- DimensionOrder.docx
- (74.67 KiB) Downloaded 289 times
-
- MVP
- Posts: 214
- Joined: Tue Nov 11, 2008 11:57 pm
- OLAP Product: TM1, CX
- Version: TM1 7x 8x 9x 10x CX 9.5 10.1
- Excel Version: XP 2003 2007 2010
- Location: Hungary
Re: Rule - count
Hello,
1.
In the measure dimension you can create an element: 'Number of active stores'
Then you can write a rule:
SKIPCHECK;
...
['Number of active stores']=IF(['Sales']>0,1,STET);
...
FEEDERS;
...
['Sales']=>['Number of active stores'];
...
2. Based on you have huge number of elements in many dimensions you must use SKIPCHECK / FEEDERS statement for all rules in this cube otherwise the performance will be unacceptable.
3. Do you have any string element in your measure dimension?
If not, then the order of your dimensions should start with the measures.
Please check the following topic:
http://forums.olapforums.com/viewtopic.php?f=3&t=1811
Regards,
Peter
1.
In the measure dimension you can create an element: 'Number of active stores'
Then you can write a rule:
SKIPCHECK;
...
['Number of active stores']=IF(['Sales']>0,1,STET);
...
FEEDERS;
...
['Sales']=>['Number of active stores'];
...
2. Based on you have huge number of elements in many dimensions you must use SKIPCHECK / FEEDERS statement for all rules in this cube otherwise the performance will be unacceptable.
3. Do you have any string element in your measure dimension?
If not, then the order of your dimensions should start with the measures.
Please check the following topic:
http://forums.olapforums.com/viewtopic.php?f=3&t=1811
Regards,
Peter
Best Regards,
Peter
Peter
-
- MVP
- Posts: 214
- Joined: Tue Nov 11, 2008 11:57 pm
- OLAP Product: TM1, CX
- Version: TM1 7x 8x 9x 10x CX 9.5 10.1
- Excel Version: XP 2003 2007 2010
- Location: Hungary
Re: Rule - count
Hello,davekerby wrote:Hi,
Thanks for your response. I've applied the fucntion ELCOMPN to the rules, however it takes a very long time to save the rule and open the cube now.
Any suggestions why this might be?
The ELCOMPN function is not useful for you since you need a Sales value driven counting and not a simple count of the dimension element of the store dimension.
Regards,
Peter
Best Regards,
Peter
Peter
-
- Posts: 11
- Joined: Mon Nov 09, 2009 2:49 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2007
Re: Rule - count
Thanks kpk,
I've just got a few qustions in regards to the store count rule. You said this should do the trick
SKIPCHECK;
...
['Number of active stores']=IF(['Sales']>0,1,STET);
...
FEEDERS;
...
['Sales']=>['Number of active stores'];
...
However wont this just put a 1 against any element that has a sale associated with it no matter if its a product or sales manager and so on? What i'd like to achieve is (attached) if i have the products in the rows and sales for each year in the columns, i also want the number of stores that have sold those products.
Hope this helps..
I've just got a few qustions in regards to the store count rule. You said this should do the trick
SKIPCHECK;
...
['Number of active stores']=IF(['Sales']>0,1,STET);
...
FEEDERS;
...
['Sales']=>['Number of active stores'];
...
However wont this just put a 1 against any element that has a sale associated with it no matter if its a product or sales manager and so on? What i'd like to achieve is (attached) if i have the products in the rows and sales for each year in the columns, i also want the number of stores that have sold those products.
Hope this helps..
-
- MVP
- Posts: 214
- Joined: Tue Nov 11, 2008 11:57 pm
- OLAP Product: TM1, CX
- Version: TM1 7x 8x 9x 10x CX 9.5 10.1
- Excel Version: XP 2003 2007 2010
- Location: Hungary
Re: Rule - count
Hello,
You can refine the rule to eliminate multiplication of number of stores by unnecessary dimensions (eg. manager, department).
SKIPCHECK;
...
['Number of active stores','dummy department','dummy manager',.....]=IF(['Sales','Total Department','Total Manager', .......]>0,1,STET);
...
FEEDERS;
...
['Sales','Total Department','Total Manager',.....]=>['Number of active stores','dummy department','dummy manager',.....];
...
On the other hand I suppose this cube stores only actual data (you do not have any version dimension).
Therefore from performance point of view you can try to load the calculated number of the stores from your relational database into the above suggested combination.
It has some overhead during the upload, but could increase the performance of the reporting.
Regards,
Peter
You can refine the rule to eliminate multiplication of number of stores by unnecessary dimensions (eg. manager, department).
SKIPCHECK;
...
['Number of active stores','dummy department','dummy manager',.....]=IF(['Sales','Total Department','Total Manager', .......]>0,1,STET);
...
FEEDERS;
...
['Sales','Total Department','Total Manager',.....]=>['Number of active stores','dummy department','dummy manager',.....];
...
On the other hand I suppose this cube stores only actual data (you do not have any version dimension).
Therefore from performance point of view you can try to load the calculated number of the stores from your relational database into the above suggested combination.
It has some overhead during the upload, but could increase the performance of the reporting.
Regards,
Peter
Best Regards,
Peter
Peter
-
- MVP
- Posts: 3703
- Joined: Fri Mar 13, 2009 11:14 am
- OLAP Product: TableManager1
- Version: PA 2.0.x
- Excel Version: Office 365
- Location: Switzerland
Re: Rule - count
You could use the ConsolidateChildren function but I wouldn't recommend it in a large (or even moderately sized) cube as it is a real performance killer.
You are better off to calculate on load and populate into a smaller cube with appropriate dimensionality or else do as Peter has suggested and write a narrowly defined rule that applies only to All Depts and All Managers etc.
You are better off to calculate on load and populate into a smaller cube with appropriate dimensionality or else do as Peter has suggested and write a narrowly defined rule that applies only to All Depts and All Managers etc.
-
- Posts: 11
- Joined: Mon Nov 09, 2009 2:49 pm
- OLAP Product: TM1
- Version: 9.4
- Excel Version: 2007
Re: Rule - count
Thanks Peter,
Can you elaborate on you suggestion, im fairly new to TM1 and dont fully understand
['Number of active stores','dummy department','dummy manager',.....]=IF(['Sales','Total Department','Total Manager', .......]>0,1,STET);
Whats is the dummy department and manager and Total Department and Manager in the IF statement? You mentioned that I refine the rule to eliminate multiplication of number of stores by unnecessary dimensions are the dummy department the dimension names?
Regards
Dave
Can you elaborate on you suggestion, im fairly new to TM1 and dont fully understand
['Number of active stores','dummy department','dummy manager',.....]=IF(['Sales','Total Department','Total Manager', .......]>0,1,STET);
Whats is the dummy department and manager and Total Department and Manager in the IF statement? You mentioned that I refine the rule to eliminate multiplication of number of stores by unnecessary dimensions are the dummy department the dimension names?
Regards
Dave