Skip to Content
avatar image
Former Member

dynamic number format in crystal report

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.

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

5 Answers

  • Best Answer
    Oct 17, 2016 at 09:04 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • Oct 14, 2016 at 06:46 PM

    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

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 01, 2016 at 08:15 PM

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Nov 01, 2016 at 04:36 PM

    .

    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.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 21, 2016 at 11:41 AM

    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

    ""

    Add comment
    10|10000 characters needed characters exceeded