Categories
- All Categories
- 15 Oracle Analytics Sharing Center
- 15 Oracle Analytics Lounge
- 208 Oracle Analytics News
- 41 Oracle Analytics Videos
- 15.7K Oracle Analytics Forums
- 6.1K Oracle Analytics Idea Labs
- Oracle Analytics User Groups
- 76 Oracle Analytics Trainings
- 14 Oracle Analytics Data Visualizations 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