N and C rules

Post Reply
buoyant
Posts: 10
Joined: Mon Apr 18, 2011 5:09 am
OLAP Product: TM1
Version: 10.2.0
Excel Version: 2013

N and C rules

Post by buoyant »

Hello Everybody,

Am trying to calculate budget variance percentage. It works fine at 'N' level but doesn't at 'C' level.
Pls can you review the following code and help me.

Thanks :D


SKIPCHECK;

['Variance'] = N: ['Actual'] - ['Budget'] ;
['Variance'] = C: ['Actual'] - ['Budget'] ;

['%Variance'] = N: (['Variance'] \ ['Budget']) * 100;
['%Variance'] = C: (['Variance'] \ ['Budget']) * 100;

FEEDERS;
['Budget'] => ['Variance'];
['Actual'] => ['Variance'];
['Budget'] => ['%Variance'];
['Actual'] => ['%Variance'];

ADMIN NOTE: Moved from the useful code tips and tricks forums
Wim Gielis
MVP
Posts: 3233
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Averages for Consolidations

Post by Wim Gielis »

Hello buoyant

Put it on the same line:

Code: Select all

['Variance'] = N: ['Actual'] - ['Budget'] ; C: ['Actual'] - ['Budget'] ;
Please post in the correct subforum, not in the "Useful code, tips and tricks" subforum.

Wim
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
Michel Zijlema
Site Admin
Posts: 712
Joined: Wed May 14, 2008 5:22 am
OLAP Product: TM1, PALO
Version: both 2.5 and higher
Excel Version: 2003-2007-2010
Location: Netherlands
Contact:

Re: Averages for Consolidations

Post by Michel Zijlema »

buoyant wrote:Hello Everybody,

Am trying to calculate budget variance percentage. It works fine at 'N' level but doesn't at 'C' level.
Pls can you review the following code and help me.

Thanks :D


SKIPCHECK;

['Variance'] = N: ['Actual'] - ['Budget'] ;
['Variance'] = C: ['Actual'] - ['Budget'] ;

['%Variance'] = N: (['Variance'] \ ['Budget']) * 100;
['%Variance'] = C: (['Variance'] \ ['Budget']) * 100;

FEEDERS;
['Budget'] => ['Variance'];
['Actual'] => ['Variance'];
['Budget'] => ['%Variance'];
['Actual'] => ['%Variance'];
Two remarks here:

If the calculation should work at all levels you don't need to specify the N: or C:, so
['%Variance'] = (['Variance'] \ ['Budget']) * 100;
will do.

If you just want to calculate the difference ['Actual'] - ['Budget'] I would advise you to make 'Variance' a consolidated element with components 'Actual' (weight 1) and 'Budget' (weight -1).

The fact that your above rules are not working for the C: part is probably because you need the AllowSeparateNandCRules parameter in your tm1s.cfg file (or rephrase like Wim just mentioned).

Michel
buoyant
Posts: 10
Joined: Mon Apr 18, 2011 5:09 am
OLAP Product: TM1
Version: 10.2.0
Excel Version: 2013

Re: Averages for Consolidations

Post by buoyant »

Thanks Wim it works.

Pls let me know what would be the appropriate subforum for this post, as i have another issue with the same topic.

Secondly, why did it work now and not with earlier code.

Thanks Michael it was a great suggestion, i would love to use it in my future designs.

Thanks again for yr help.

Regards
Wim Gielis
MVP
Posts: 3233
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.1.5
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Averages for Consolidations

Post by Wim Gielis »

You can create your new topic in this general subforum:

http://www.tm1forum.com/viewforum.php?f=3
Best regards,

Wim Gielis

IBM Champion 2024-2025
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
Post Reply