Page 1 of 1
What is correct way to write TM1 rule.
Posted: Mon Mar 30, 2020 2:18 pm
by Ashleigh W
Hi Experts, 'm back with a question.
I'm confused on how to place dynamic objects on Left side of rule. I tried below but it errors. I actually want the right side to be a look up from another cube.
[!}Cubes, !}Groups] = S: 'READ';
do i write as below?
[] = S: DB('my_cube', !}Cubes, !}Groups, 'Permission');
thanks in advance.
Re: What is correct way to write TM1 rule.
Posted: Mon Mar 30, 2020 2:36 pm
by ascheevel
Did you try the second option you noted and did it work?
Re: What is correct way to write TM1 rule.
Posted: Mon Mar 30, 2020 2:51 pm
by Ashleigh W
thanks, second option seem to work yes.
Is there any way to refer to elements in below fashion (LEFT Side) ?
[!}Cubes, !}Groups] = S: 'READ';
Re: What is correct way to write TM1 rule.
Posted: Mon Mar 30, 2020 3:16 pm
by ascheevel
Ashleigh W wrote: ↑Mon Mar 30, 2020 2:51 pm
[!}Cubes, !}Groups] = S: 'READ';
Assuming then that your cube has dimensions "}Cubes" and "}Groups"? What you've written is the same as:
Dynamic on the left would just be referencing itself and would always apply. Perhaps you can share more details around what you're trying to accomplish and why you think dynamic on the left is needed. AFIAK, !<dim> on the left doesn't work in rules because it'd be the same as [].
Said another way, the !<dim> is already implied on the left for a rule that doesn't explicitly specify elements for that dimension. For example, if you have a 4 dim sales cube: Customer, Product, Time, Measure and the measure dim has measures like "quantity", "price", and "total sales". If you wrote a rule for Total Sales to be equal to quantity times price, the rule would look like this:
Code: Select all
['Total Sales'] = N:['Quantity'] * ['Price'];
The measure dim is the only dim defined on the left side and the rule will therefore apply to all elements in all other dims. That's the same as if you could write the rule as:
Code: Select all
[!Customer, !Product, !Time, 'Total Sales'] = N:['Quantity'] * ['Price'];
The !<dim> callouts on the left are already implied and therefore not needed. Perhaps this is the reason it's a not a valid way to write a rule.
Re: What is correct way to write TM1 rule.
Posted: Mon Mar 30, 2020 5:09 pm
by tomok
If you keep in mind the logic for a rules statements is as follows:
then you'll understand why you can't use dynamic values on the left hand side. If you don't specify a value on the left hand side of a rule for a specific dimension then it means all elements of that dimension. That's it, you either identify a specific value or ALL. If you want the assignment to be "dynamic" then you need to put it on the right-hand side and use IF logic.
Re: What is correct way to write TM1 rule.
Posted: Mon Mar 30, 2020 5:10 pm
by lotsaram
Ashleigh W wrote: ↑Mon Mar 30, 2020 2:51 pm
thanks, second option seem to work yes.
Is there any way to refer to elements in below fashion (LEFT Side) ?
[!}Cubes, !}Groups] = S: 'READ';
Yes. Any dimension omitted within square brackets (i.e. left hand OR right hand side) is implicitly unfiltered or "ALL". Or in other words same as !dimension within a DB() reference on the RHS.
Re: What is correct way to write TM1 rule.
Posted: Tue Mar 31, 2020 7:25 am
by Ashleigh W
Thanks ascheevel, tomok and lotsaram. Your answers gave me much more clarity.