Introduction

To apply number formatting to a dynamic variable, the Format Number Hash Plugin can be used. To do so, Nested hash variable formatting can be utilized to achieve number formatting with a dynamic variable when using the Format Number Hash Plugin.


Using Format Number Hash on Datalist

Similar to Format Number Hash for form #formatNumber.{form.table.field}[decimal=2], you can use a similar approach to formatting numbers retrieved from a datalist. When you have a hash variable that holds the sum or any numerical data from a datalist, you can format this number by placing it inside the Format Number Hash syntax. This allows you to specify the desired number of decimal places or other formatting options.

For example, if you have a sum of a datalist column being retrieved dynamically, you can add a thousand separators and decimals to it like so:

#formatNumber.{Your_datalist_hash}[decimal=2&thousandSeparator=,]#


For example, if there is a datalist named list_MoneyFlower, the hash variable will be

#formatNumber.{datalist.col.sum.list_MoneyFlower.column_1}[decimal=2&thousandSeparator=,]#

 

Figure 1: Datalist

This will format your dynamic sum with two decimal places and include a comma as the thousand separator, see figure 2

Figure 2: Number formatting on the sum of a datalist column

Format Number Hash on the Arithmetic Operation

If you are performing arithmetic operations on data from datalists and wish to apply number formatting to the aggregated total, you can employ a nested expression hash variable. This would involve summing up the columns and then formatting the resulting total with the Format Number Hash. To learn more about using dynamic hash variable values within information tiles, please refer to the relevant documentation page use dynamic hash variable values inside information tiles 

 If you want to have the number formatted on the total value, The hash variable expression for that would be:

#formatNumber.{exp.{envVariable.num1} + {envVariable.num2}}[decimal=2&thousandSeparator=,]#

For example, if you have 4 datalists and you want to add the sum of columns and apply Format Number Hash on the total value, the format would be

#formatNumber.{exp.{datalist.col.sum.list_Money_University.column_0} + {datalist.col.sum.list_Money_Resort.column_0} + {datalist.col.sum.list_Money_Hamburger_Shop.column_0} + {datalist.col.sum.list_MoneyFlower.column_1}}[decimal=2&thousandSeparator=,]#



Figure 3: Formatting the total value 

Know more at Hash Variable, under the Expression Hash Variable (New) section, on how to use different expressions.

Also, refer to the Format Number Hash Plugin, to learn how to format numbers.

Download Demo App

APP_kb_dx8_FormatNumberInHash.jwa





  • No labels