Nested IFs or use Contine. What gives better performance?

Post Reply
Bakkone
Posts: 119
Joined: Mon Oct 27, 2014 10:50 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Nested IFs or use Contine. What gives better performance?

Post by Bakkone »

Hi all,

Im rebuilding some stuff at work and need some advice on what is best from a performance perspective. This cube is going to get big because of an "advanced" idea on how things should be organized.

Consider the two examples:

Example 1:

Code: Select all

['Value'] = N:
     IF( !Period <= ['PeriodBreak1'],
          ['Value1'],
               IF( !Period <= ['PeriodBreak2'],
                    ['Value2'],
                         IF( !Period <= ['PeriodBreak3'],
                              ['Value3'], ['Value4']
                         )
               )
     ) ;

Example 2:

Code: Select all

['Value'] = N:
     IF( !Period <= ['PeriodBreak1'],
          ['Value1'],
          CONTINUE
     ) ;

['Value'] = N:
     IF( !Period <= ['PeriodBreak2'],
          ['Value2'],
          CONTINUE
     ) ;

['Value'] = N:
     IF( !Period <= ['PeriodBreak3'],
          ['Value3'],
          ['Value4']
     ) ;
Currently the new rebuilt model is small and I can't notice any difference in performance. I do however have other similar parts of the solution that is built more like Example 2. Im not that experienced but I find those parts of the model to have surprisingly fast performance considering the size. That is compared to other stuff I made like Example 1. But i could be imagining things, and there are other factors that affect performance.

So does anyone know if Example 1 or Example 2 is better from a performance perspective? Someone thats been doing this a lot longer than I have? I looked around for a best practice but found none.

Regards
David
BariAbdul
Regular Participant
Posts: 424
Joined: Sat Mar 10, 2012 1:03 pm
OLAP Product: IBM TM1, Planning Analytics, P
Version: PAW 2.0.8
Excel Version: 2019

Re: Nested IFs or use Contine. What gives better performance?

Post by BariAbdul »

Personally,I would prefer second option ,Just to reduce no of conditional tests and IF statements.Thanks
"You Never Fail Until You Stop Trying......"
User avatar
qml
MVP
Posts: 1097
Joined: Mon Feb 01, 2010 1:01 pm
OLAP Product: TM1 / Planning Analytics
Version: 2.0.9 and all previous
Excel Version: 2007 - 2016
Location: London, UK, Europe

Re: Nested IFs or use Contine. What gives better performance?

Post by qml »

There shouldn't be any measurable performance difference between these two approaches, because in both the engine needs to perform the same number of tests to produce every requested figure.

I prefer the nested IFs because of calculation traceability. For me it is easier to read and decode when a calculation is implemented in a single formula. If it's spread across multiple formulas, especially if they sit in different areas of a large rule file, it can become harder to debug, maintain or change. Of course, there is also a limit to how many nested IFs in a single formula can be reasonably taken in and decoded. I've never had to work with more than about 4 (which means 16 different outcomes), but if I absolutely had to have more I would consider breaking them down using CONTINUE.

The bottom line is that there isn't a clear best practice because it is largely an area of personal preference and circumstance. From my experience performance does not come into play with this particular question.
Kamil Arendt
Bakkone
Posts: 119
Joined: Mon Oct 27, 2014 10:50 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: Nested IFs or use Contine. What gives better performance?

Post by Bakkone »

Thanks for your replies. I sent the question to IBMs product team as well. I will update you if I get a reply.

I prefer the nested IFs as well as I can then clearly see how a measure is calculated, without having to look in the entire rule-file for variants.

I do use continue at the top of a rule file if I have any conditional calculations where I want to opt out large chunks of the cube from calculations. Say for example that all historical values are supposed to be STET, or inactive periods or something.

Regards
David
Post Reply