Hi,
Is it possible to show negative figures in brackets? For example, the following code:
{% assign example = (5-10) %} {{ example | integer }}
Will provide the result: -5
Is there a way to show this as (5)
instead?
Many thanks
Joe
Hi,
Is it possible to show negative figures in brackets? For example, the following code:
{% assign example = (5-10) %} {{ example | integer }}
Will provide the result: -5
Is there a way to show this as (5)
instead?
Many thanks
Joe
Hi @jhanley,
This can be done by using the ‘currency_dc’-filter.
{% assign example = (5-10) %} {{ example | currency_dc:0 }}
This will provide the requested result (i.e. (5)).
Note that the :0
is included in the code to limit the decimals. When you just use currency_dc
the result will show 2 decimals.
Hope this was what you were looking for!
Kind regards,
Robin
Hi @robindeclercq,
Thanks for the quick response!
This looks to achieve what I’m after, though I’m not having much luck at producing the (5)
result
I copied the code you provided as a test, but this is still pulling through as -5
?
Kind regards
Joe
Hi @jhanley,
You’re totally right, my bad! I was a bit too quick with the response.
Next to the currency_dc
filter you should also make sure that the settings in your environment are set to show negative amounts as (X)
instead of -X
.
To do so, the administrator in your environment should go to ‘Advanced’
Then to ‘Currency negative format’
And change -xxx
to (xxx)
These settings in combination with currency_dc
will make sure that negative numbers are always shown with brackets.
Kind regards,
Robin
Thanks @robindeclercq, that makes perfect sense! I haven’t been able to test this yet as our admin user is not available, but I’m positive this will resolve my issue.
Thanks for all your help!
Joe
PS @jhanley,
this is explained here as well:
The activation of those currency format is not something regular user can do by the way.