Skip to Content
0

dynamic number format in crystal report

Oct 14, 2016 at 06:44 PM

53

avatar image

Hi,

Could anyone help me on how to dynamically format a column number in crystal 2008

This is the table

Header. Jan Feb Mar

Contracts. 20 30 50

Sale amount. $10 $40 $50

Profit. 3% 4% 8%

All these are in detail section.the header ( contracts,sale ,) are from dB fields.

10 |10000 characters needed characters left characters exceeded

i would like to add $,% symbol to the value based on condition.

If sales the value displayed should be in $ format.if profit the value should be in % format.

For now I have explained in excel.

0
* Please Login or Register to Answer, Follow or Comment.

5 Answers

Best Answer
Brian Dong Oct 17, 2016 at 09:04 AM
0

Hi Lalitha,

One way to do this would be to have a formula convert the numbers to a string then format according to the record type like:

Select {Orders.Customer ID} 
    Case "sales": "$" & ToText ({Orders.Order Amount}) 
    Case "profit": ToText ({Orders.Order Amount}, 0, "") & "%"
    Case "contracts": ToText ({Orders.Order Amount}, 0, "") 
    Default: ToText ({Orders.Order Amount}); 

You can right justify the columns when done.

Good luck,

Brian

Share
10 |10000 characters needed characters left characters exceeded
Abhilash Kumar
Oct 14, 2016 at 06:46 PM
0

Hi Lalitha,

Could you elaborate on 'dynamically format a column'?

You'd need to highlight a particular column and use the formatting toolbar on the top to either insert a % sign or a currency symbol.

-Abhilash

Share
10 |10000 characters needed characters left characters exceeded
Lalitha Sekar Nov 01, 2016 at 08:15 PM
0

if my header has value "profit" then the values displayed for each month should be in %format

If "sales" then the value displayed should be in $format.

Hope I explained better.

Share
10 |10000 characters needed characters left characters exceeded
Lalitha Sekar Nov 01, 2016 at 04:36 PM
0

.

i would need to format the same object as % ,$ based on condition dynamically .

If the header value is "sales" the value displayed for each month should be in $ whereas if "profit" the value against each month in %

For now I have explained in excel.


Share
10 |10000 characters needed characters left characters exceeded
Lalitha Sekar Oct 21, 2016 at 11:41 AM
0

Thank You ! for your suggestion.

I came up with one more solution to achieve the same . If we use totext formulae the numbers will be changed to text format.To display Negative values and while exporting to excel we need to retain number format. we can do it as right click on the field (tablename.object}in the format field->select the number format ->customize->in the currency symbol tab (check on ->enable currency symbol ->floating->

select currency symbol->type a formula with in it as below

local stringvar string1:={orders.Header);

if {orders.Header)="sales" then "$"

else if {orders.Header)="Profit" then "%"

else

""


format.jpg (24.4 kB)
Share
10 |10000 characters needed characters left characters exceeded