How to truncate inside of a set_variable formula? — Oracle Analytics

Oracle Analytics Cloud and Server

Welcome to the Oracle Analytics Community: Please complete your User Profile and upload your Profile Picture

How to truncate inside of a set_variable formula?

Received Response
11
Views
1
Comments

Summary

How to truncate inside of a set_variable formula?

Content

Hi All,

It appears I can not use Truncate within a set_variable call (even though I can use round). What can I do instead of truncate, to produce the same results?

<?for-each-group:current-group();./I.TOTAL_AMT?><?sort:current-group()/I.TOTAL_AMT;'ascending';data-type='text'?>

<?for-each:current-group()?>

<?xdoxslt:set_variable($_XDOCTX, 'var', 0)?>

<?xdoxslt:set_variable($_XDOCTX, 'var', round(((SUM_LIMIT_AMT * 1.05) div 100000) + 1) * 100000)?>

<?end for-each?>

/* Print running 'var' total*/

<?xdoxslt:set_variable($_XDOCTX,'var', xdoxslt:get_variable($_XDOCTX, 'var') + round(((SUM_LIMIT_AMT * 1.05) div 100000) + 1) * 100000))?> <?xdoxslt:get_variable($_XDOCTX, 'var')?>

<?end for-each-group?>

Thanks.

John

Answers

  • timdexter
    timdexter Rank 6 - Analytics Lead

    Hi John

    Couple of points.

    1. The set|get variable functions were created because native XSL does not support the concept of an updateable variable. It has variables as you might read but these are more like constants. XSL wants you to use recursion to handle updating values. In a complex report, things can get a little complicated, so we introduced updateable variables.

    2. Within the set variable you can use round but need to be explicit about truncate because 'round' is a native XSL function while truncate is a BIP created function. Now, it might be worth trying the complete truncate function inside the set variable i.e.<span class="variable"></span><span class="variable"></span>

    <?xdoxslt:set_variable($_XDOCTX, 'var', xdoxslt:truncate ( <span class="variable">number</span> [, <span class="variable">integer</span> ] ))?>

    3. Failing that, when you finally use the get function to show the variable value. Try using native field formatting or the format-number function to get the rounding and decimal places as you need them

    Regards

    Tim