Categories
- All Categories
- Oracle Analytics and AI Learning Hub
- 39 Oracle Analytics and AI Sharing Center
- 20 Oracle Analytics and AI Lounge
- 276 Oracle Analytics and AI News
- 50 Oracle Analytics and AI Videos
- 16.2K Oracle Analytics and AI Forums
- 6.4K Oracle Analytics and AI Idea Labs
- Oracle Analytics and AI User Groups
- 102 Oracle Analytics and AI Trainings
- 17 Oracle Analytics and AI Challenge
- Find Partners
- For Partners
How to truncate inside of a set_variable formula?
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
-
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
0