Applying styles

(3 posts) (2 voices)

Tags:

No tags yet.

  1. Dev, Member

    Hi,

    I am trying to conditionally format from the query data itself instead of using a calculated column in the dbr command. I want to apply conditional formatting to the columns from the query itself.

    How can I conditionally format based on the query data itself?

    For example, if the column 'Allocated' value is higher than the column 'Appts Check Outs', I want the value to appear in red. If it is lower, I want it to appear in green. The format below didnt work. Pls guide me on this.

    -- Define the styles
    select 'dbr.css', '.text_green {color:green}';
    select 'dbr.css', '.text_red {color:red}';

    -- Format data cells and the footer alike
    select 'dbr.cellclass', 'Diff', 'color';
    select 'dbr.footer.cellclass', 'Diff', 'color';

    select 'dbr.sum', 'Value', 'Budget';
    select 'dbr.calc', 'Diff', '[Value] - [Budget]';

    -- Calculate the CSS class to be used
    select 'dbr.calc', 'color', "[Value]>=[Budget] ? 'text_green' : 'text_red'";

    Thank you

  2. myDBR Team, Key Master

    It's easier to use a separate column for this:

    select 'dbr.css', '
    .text_green {color:green}
    .text_red {color:red}
    '; -- Format data cells and the footer alike
    select 'dbr.cellclass', 'Diff', 'color';
    select 'dbr.footer.cellclass', 'Diff', 'color'; select 'dbr.sum', 'Value', 'Budget';
    select 'dbr.calc', 'Diff', '[Value] - [Budget]'; select Value, Budget, null as Diff, if (Value>=Budget, 'text_green', 'text_red') as 'color'
    from yourtable;

    --
    myDBR Team

  3. Dev, Member

    Hi,

    The above suggestions worked well, Thank you.


Reply

You must log in to post.