dbr.calc doesn't appear to be too happy with negative numbers

(6 posts) (2 voices)

Tags:

No tags yet.

  1. hubcarter, Member

    I have been using the 'dbr.calc' command to obtain percentages at both line and summary level. All works well unless the result is negative in which case it returns 0.

  2. myDBR Team, Key Master

    Hi,
    could you show your dbr.calc definition and tell which data gets a negative value?

    --
    myDBR Team

  3. hubcarter, Member

    select 'dbr.sum','TC','TX','TI';
    select 'dbr.calc','pcnt','(([TI]-[TX]-[TC])*100)/([TI]-[TX])';

    select b.invNum as 'InvNum',
    b.totCost as'TotCost[TC]',
    null as 'G/P%[pcnt]',
    b.taxAmt as 'TaxAmt[TX]',
    b.totInvAmt as 'TotInvAmt[TI]'
    FROM pxplus.bi_invHdr b

    Example from 1 record:

    totInvAmt = -200.26
    TaxAmt = -15.26
    TotCost = -97.56

    Malcolm Carter - Hub...
    ........................

  4. myDBR Team, Key Master

    Hi,
    dbr.calc is a formula that is eventually sent to be evaluated by PHP. When you have negative numbers, you can put the variables in the parenthesis. PHP does not like formulas like 3--2. It however is ok with 3-(-2).

    myDBR could do this automatically so we'll put it in as a CR.

    --
    myDBR Team

  5. hubcarter, Member

    Added the parentheses and all is well. Thank you very much.. (For both accurate and rapid response).

    Malcolm C. - Hub

  6. myDBR Team, Key Master

    We've added the automatic dbr.calc parentheses in the latest build. Makes the dbr.calc formulas bit easier to read.

    --
    myDBR Team


Reply

You must log in to post.