cancel
Showing results for 
Search instead for 
Did you mean: 

dynamic number format in crystal report

Former Member
0 Kudos

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.

Former Member
0 Kudos

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.

Accepted Solutions (1)

Accepted Solutions (1)

former_member292966
Active Contributor
0 Kudos

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

Answers (4)

Answers (4)

Former Member
0 Kudos

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.

Former Member
0 Kudos

.

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.

Former Member
0 Kudos

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

""

abhilash_kumar
Active Contributor
0 Kudos

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