TM1 if statement issue

Post Reply
ssadoglu
Posts: 4
Joined: Thu Mar 06, 2014 9:54 am
OLAP Product: tm1
Version: 10.1
Excel Version: 2007

TM1 if statement issue

Post by ssadoglu »

Hello,

I've been using TM1 10.2.I'm newbie. I have a problem related to the if function.
Here is my rule :

Code: Select all

['Brüt Kar' ] = (DB('Satýþ ve Maliyet', !Aylar, !products, 'Satýþ', !Senaryolar, !Yýllar, !Ülkeler, !Stroes)
              + DB('Satýþ ve Maliyet', !Aylar, !products, 'Maliyet', !Senaryolar, !Yýllar, !Ülkeler, !Stroes));

['Sales' ] = N: DB('Satýþ ve Maliyet', !Aylar, !products, 'Satýþ', !Senaryolar, !Yýllar, !Ülkeler, !Stroes);

['Gider' ] = N: DB('gider', !Aylar, 'Toplam Giderler', !products, !Stroes, !Senaryolar, !Ülkeler, !Yýllar);

['Toplam Maliyet'] = N: DB('Satýþ ve Maliyet', !Aylar, !products, 'Maliyet', !Senaryolar, !Yýllar, !Ülkeler, !Stroes);

['Net Kar' ]  = N: (['Sales' ] - ( ['Gider' ] + ['Toplam Maliyet' ] ));

['Net Zarar'] = N:  IF(['Net Kar'] >0, 0, CONTINUE);
['Net Zarar'] = N:  IF(['Net Kar'] <0, ['Net Kar'], CONTINUE);

Net Kar is less than zero value. Net Kar would be zero value and Net Zarar would be equal first value of "Net Kar".

E.g :

First statement :
Net Kar :- 1200
Net Zarar : NULL
Second statement:
Net Kar : 0
Net zarar : -1200




Thanks in advance,

Kind Regards,
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: TM1 if statement issue

Post by David Usherwood »

Your first rule sets Net Zarar based on Net Kar being positive, if not the second rule applies. Net Kar won't be affected by either rule as it's set in the line above. Remember rules are declarative, not procedural (like Excel formulae) - the first assignment which applies is the one which is used.

Code: Select all

['Net Kar' ]  = N: (['Sales' ] - ( ['Gider' ] + ['Toplam Maliyet' ] ));
['Net Zarar'] = N:  IF(['Net Kar'] >0, 0, CONTINUE);
['Net Zarar'] = N:  IF(['Net Kar'] <0, ['Net Kar'], CONTINUE);
ssadoglu
Posts: 4
Joined: Thu Mar 06, 2014 9:54 am
OLAP Product: tm1
Version: 10.1
Excel Version: 2007

Re: TM1 if statement issue

Post by ssadoglu »

David Usherwood wrote:Your first rule sets Net Zarar based on Net Kar being positive, if not the second rule applies. Net Kar won't be affected by either rule as it's set in the line above. Remember rules are declarative, not procedural (like Excel formulae) - the first assignment which applies is the one which is used.

Code: Select all

['Net Kar' ]  = N: (['Sales' ] - ( ['Gider' ] + ['Toplam Maliyet' ] ));
['Net Zarar'] = N:  IF(['Net Kar'] >0, 0, CONTINUE);
['Net Zarar'] = N:  IF(['Net Kar'] <0, ['Net Kar'], CONTINUE);
Hi David,

This rule isn't working. So I mean finally Net Kar must be zero value. But , it's not working. I want to do like below. if I work above "if condition" I'm getting the following result.
Net Kar : - 1200
Net zarar : -1200

Finally , I want to do :
if Net Kar < 0 ;

Net Kar : 0
Net zarar : -1200

Thanks , regards,
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: TM1 if statement issue

Post by David Usherwood »

But you set Net Kar in the first rule and you can't then change it later - in fact your later rules only affect Net Zarar anyway. Be clear - Rules are declarative not procedural - once a rule applies that's it.
ssadoglu
Posts: 4
Joined: Thu Mar 06, 2014 9:54 am
OLAP Product: tm1
Version: 10.1
Excel Version: 2007

Re: TM1 if statement issue

Post by ssadoglu »

David Usherwood wrote:But you set Net Kar in the first rule and you can't then change it later - in fact your later rules only affect Net Zarar anyway. Be clear - Rules are declarative not procedural - once a rule applies that's it.
Ok. How can I modify my rule? I'm a few confused.

Thanks & Regards,
David Usherwood
Site Admin
Posts: 1458
Joined: Wed May 28, 2008 9:09 am

Re: TM1 if statement issue

Post by David Usherwood »

What's the business problem you are trying to solve?
ssadoglu
Posts: 4
Joined: Thu Mar 06, 2014 9:54 am
OLAP Product: tm1
Version: 10.1
Excel Version: 2007

Re: TM1 if statement issue

Post by ssadoglu »

David Usherwood wrote:What's the business problem you are trying to solve?
Hello David,

OK. Like you said you are correct. I've changed the first line within rule. I've defined different column except "Net Kar". it works.

Kind regards,
roy2087
Posts: 40
Joined: Wed Feb 06, 2013 9:53 am
OLAP Product: cognos tm1
Version: 10.1.1
Excel Version: 2007
Location: Bangalore,India

Re: TM1 if statement issue

Post by roy2087 »

Hi,

How about using this rule:-

['Net Zarar'] = N: IF(['Net Kar'] > 0, 0 , ['Net Kar'] );


Regards,
Roy.
Post Reply