The bxp looping engine in Keystats allows a creator of a Key Stats report to ensure that the report he/she creates created is 100% dynamic , i.e . not limiting the report to a set number of time intervals or to a set number of forms.The looping engine of Key Stats should be used in conjunction with the numerous dynamic replacements that bxp key stats module provides or with the user specified custom replacements.
The looping engine greatly enhances the reporting ability of any Key Stats Keystats report by enabling the creation of 100% dynamic and customisable reports, that could meet any user needsmany different requirements. When creating a Key Stats Keystats Report using the looping engine, there are two loop types available: ''Outer Loop'' and ''Internal Loop''. The number of ''Outer Loops'' are as required, same with ''Internal Loops''. However, every ''Internal Loop'' cannot have another ''Internal Loop'' inside of it.
When adding loops to a Key Stat Keystat report, the loops can be added at two levels, ''Tab level'' and ''Graphic level''.
In coding terms the looping engine of the bxp Key Stats Keystats module handles the same as the conventional ''FOR loop'', i.e. Loop the following for X times.
Anything in between the Start and End Loop tags will be repeated the set number of times specified. The looped content can be anything: HTML, JavaScript, Key StatsKeystats, Internal Loops, or even the entire Key Stats Keystats report.
Anything in between the Start and End Loop tags will be repeated the set number of times specified. The looped content can be anything: HTML, JavaScript, Key StatsKeystats, Internal Loops or even the entire Key Stats report.
<syntaxhighlight lang="html4strict">
When creating a Graphic Key StatsKeystats, perform the same looping options as above, but instead of adding the looping syntax to the Key Stat Keystat Tab, the syntax gets added to the actual KeyStat Keystat that is generating the graphic. The same Key Stat Keystat syntax is used for both the Outer and Internal Loops.
<syntaxhighlight lang="html4strict">
== Dynamic Replacements ==
The Key Stats Keystats looping engine allows the use of dynamic replacements. These dynamic replacements include the current count of the loop. The current loop count can be replaced as many times as required.
To perform this replacement the following key words should be used:-
When using the user set dynamic replacements ''keyStatsCustom'', modify the parameters inside an SQL statement. For example, if the statement that counts the number of contacts (CCL's) happens between two dates, by using the Looping engine the report is set up to allow an indefinite amount of dates to be passed in. Instead of creating a different key stat for every iteration of the parameters, use key stats, but replace the parameters that gets passed to it. To use the dynamic replacements for the parameters passed in, use the foollowing following syntax (but make sure it is the very last parameter passed to the key stat:
As a Key Stat Keystat can have multiple parameters to replace, specify where in the statement to perform the replacement. To do this add a specific key word to the places in the SQL statement that need to be replaced. This key word is ''[[intParamAdd]]''. When the Key Stats Keystats engine sees this it will replace it with the required value, as outlined above.