Colour with dbr.calc

(3 posts) (2 voices)

Tags:

No tags yet.

  1. xerxes42, Member

    Hi

    I have a calculated column called diff and depending on how large the diff is it should be red or green. If I want all with diff less than 10 to be green I use:

    select 'dbr.calc', 'diff', '[Expected Value]-[Actual Value]'; select 'dbr.calc', 'color', "[diff]<=10 ? 'text_green' : 'text_red'";

    But I also want that if the diff is less than -10 it should be displayed as red again. What I want is to be able to say: All rows with diff between -10 and 10 should be green all other red.

    Any hints on how I can do this in MyDBR?

    Brgds
    Olof

  2. myDBR Team, Key Master

    Olof,
    myDBR accepts any PHP expression in dbr.calc. So you can do:

    select 'dbr.calc', 'color', "([diff]<-10 || [diff]>10 ) ? 'text_red' : 'text_green'";

    Alternatively, you can do that directly in SQL, but then you would need to to the calculation in SQL.
    --
    myDBR Team

  3. xerxes42, Member

    Thanks a lot!

    Usually I do the calculation in SQL but with this data set the diff was calculated between a value on each row and a SUM over multiple rows and then a multiple group to get it right.

    /Olof


Reply

You must log in to post.