Hi All,
I have a requirement to display a negative value with a dollar symbol and text functions but whenever I tried doing it am getting unexpected result.
For eg:
dollar(10000-30000,0) = "($20,000)" [but expected is "$20,000" an extra "(,)" is getting added due to negative symbol.
text(10000-30000,"0") = "2000-0" [but expected is "20000" an extra "-" is getting added due to negative symbol.
Do I need to pass anything specific format in the above functions to get the desired output?
Can someone please tell me what should be the format I need to use for the above scenario?
Regards,
Balaji.R
Discussion posts and replies are publicly visible
Hi rpbalaji2006 (balajir0001) there are multiple ways to achieve this requirement, hence please find the code snippet to achieve your requirement, mentioned below:
/* FOR dollar() related requirement */ /* Using Regex Pattern - using Appian Regular Expression Functions plugin */ regexreplaceall( "[()]", dollar(10000 - 30000, 0), "" ) /* OUTPUT: "$20,000" */ /* Achieving the same using String Manipulation - without plugin */ load( local!amount: dollar(10000 - 30000, 0), if( isnull(local!amount), dollar(0), replace( replace(local!amount, 1, 1, ""), len(replace(local!amount, 1, 1, "")), 1, "" ) ) ) /* OUTPUT: "$20,000" */ /* For text() requirement */ /* As you are already aware, when you subtract more amount from lesser one, you should expect negative value as it's result */ Approach 1: 10000-30000 /* OUTPUT: -20000 Type: Number (Integer) */ Approach 2: tostring(10000-30000) /* OUTPUT: "-20000" Type: Text */ /* You don't need to use text function to achieve this requirement, you can simply use one of the above approach depending upon what return type you are expecting */
Hope this will help you.