how do i custom format different columns based on values?

(6 posts) (2 voices)

Tags:

No tags yet.

  1. JMitchell, Member

    I am trying to conditionally format several columns but it seems like the entire row is color coded based on the last dbr.rowclass. Makes sense but how do i only highlight single cells in a row based on a value set

    ie:

    select 'dbr.colclass', 7, 'highlightcol';
    select 'dbr.rowclass', 24;
    select 'dbr.colclass', 9, 'highlightcol';
    select 'dbr.rowclass', 25;
    select 'dbr.colclass', 12, 'highlightcol';
    select 'dbr.rowclass', 26;
    select 'dbr.colclass', 14, 'highlightcol';
    select 'dbr.rowclass', 27;
    select 'dbr.colclass', 17, 'highlightcol';
    select 'dbr.rowclass', 28;
    select 'dbr.colclass', 19, 'highlightcol';
    select 'dbr.rowclass', 29;

    all of my columns using dbr.colclass are formatted red or green based on my last use of rowclass. (select 'dbr.rowclass', 29;)

    Does that make sense?

    and these are the appropriate rowclasss columns:
    /*row 24*/
    , case
    when ((sum(deals) / sum(web_of_120 + inbound_120_sec + outbound_120_sec + queue_60_sec)) * 100) > 5 then 'colormegreen'
    when ((sum(deals) / sum(web_of_120 + inbound_120_sec + outbound_120_sec + queue_60_sec)) * 100) < 5 then 'colormered'
    else ''
    end
    /*row 25*/
    , case
    when ((sum(backouts)/sum(deals)) * 100) > 20 then 'colormered'
    when ((sum(backouts)/sum(deals)) * 100) < 15 then 'colormegreen'
    else ''
    end
    /*row 26*/
    , case
    when (sum(overflow + web)) > 91 then 'colormegreen'
    when (sum(overflow + web)) < 91 then 'colormered'
    else ''
    end
    /*row 27*/
    , case
    when ((sum(web_of_120 + inbound_120_sec + outbound_120_sec)/sum(overflow + web))*100) > 60 then 'colormegreen'
    when ((sum(web_of_120 + inbound_120_sec + outbound_120_sec)/sum(overflow + web))*100) < 60 then 'colormered'
    else ''
    end
    /*row 28*/
    , case
    when ((sum(over_18_mo)/sum(b.sumdeal))*100) < 35 then 'colormegreen'
    when ((sum(over_18_mo)/sum(b.sumdeal))*100) >35 then 'colormered'
    else ''
    end
    /*row 29*/
    , case
    when ((sum(b.sumdp)/sum(b.sumcc))*100) > 8 then 'colormegreen'
    when ((sum(b.sumdp)/sum(b.sumcc))*100) < 8 then 'colormered'
    else ''
    end

  2. myDBR Team, Key Master

    You should have only one dbr.rowclass -column defined. You can have multiple classnames defined in it. Define a different rowclass for each column you wish to have color and a matching column class for it.

    In order to make the report easier to maintain, consider creating a function which returns the rowclass-names based on aggregates you give as parameter.

    --
    myDBR Team

  3. JMitchell, Member

    can you give me an example?

    my userstyle.css looks like this:

    tr.colormered td.highlightcol {
    background-color: red;
    color: white;
    }

    tr.colormegreen td.highlightcol {
    background-color: green;
    color: white;
    }

    another thing I am wondering is if this supports all of the css colors? ie crimson, maroon, etc

  4. myDBR Team, Key Master

    can you give me an example?

    As a quick example. You can move the css to userstyle.css:

    select 'dbr.css', 'tr.redA td.colA { background-color: red }';
    select 'dbr.css', 'tr.greenA td.colB { background-color: green }';
    select 'dbr.css', 'tr.redB td.colA { background-color: red }';
    select 'dbr.css', 'tr.greenB td.colB { background-color: green }'; select 'dbr.rowclass', 4;
    select 'dbr.colclass', 2, 'colA';
    select 'dbr.colclass', 3, 'colB'; select title, sum(colA), sum(colB), fn_rowcolor( sum(colA), sum(colB) )
    from mytable
    group by title;

    Function fn_rowcolor would return rowstyle like 'redA greenB'.

    another thing I am wondering is if this supports all of the css colors? ie crimson, maroon, etc

    Sure. It's all CSS.
    --
    myDBR Team

  5. JMitchell, Member

    ok i changed my code to the the following. only the 1st column is showing color. what am i doing wrong?

    if the 1st column (column 7) shows color and the rest are formatted the same then each column should be showing the correct color, correct?

    ***My rowclass column 24 is only showing column 7 values (reda or greena)***

    My question is how can i get column 24 to color all fields?

    select 'dbr.css', 'tr.reda td.hlcola { background-color: red; color: white; }';
    select 'dbr.css', 'tr.greena td.hlcola { background-color: green; color: white; }';
    select 'dbr.css', 'tr.redb td.hlcolb { background-color: red; color: white; }';
    select 'dbr.css', 'tr.greenb td.hlcolb { background-color: green; color: white; }';
    select 'dbr.css', 'tr.redc td.hlcolc { background-color: red; color: white; }';
    select 'dbr.css', 'tr.greenc td.hlcolc { background-color: green; color: white; }';
    select 'dbr.css', 'tr.redd td.hlcold { background-color: red; color: white; }';
    select 'dbr.css', 'tr.greend td.hlcold { background-color: green; color: white; }';
    select 'dbr.css', 'tr.rede td.hlcole { background-color: red; color: white; }';
    select 'dbr.css', 'tr.greene td.hlcole { background-color: green; color: white; }';
    select 'dbr.css', 'tr.redf td.hlcolf { background-color: red; color: white; }';
    select 'dbr.css', 'tr.greenf td.hlcolf { background-color: green; color: white; }';

    select 'dbr.rowclass', 24;
    select 'dbr.colclass', 7, 'hlcola';
    select 'dbr.colclass', 9, 'hlcolb';
    select 'dbr.colclass', 12, 'hlcolc';
    select 'dbr.colclass', 14, 'hlcold';
    select 'dbr.colclass', 17, 'hlcole';
    select 'dbr.colclass', 19, 'hlcolf';

    /*column 24 - paraphrasing for readability */
    , case
    when column7 > 5 then 'reda'
    when column7 < 5 then 'greena'
    when column9 > 20 then 'redb'
    when column9 < 15 then 'greenb'
    when column12 > 91 then 'greenc'
    when column12 < 91 then 'redc'
    when column14 > 60 then 'greend'
    when column14 < 60 then 'redd'
    when column17 < 35 then 'greene'
    when column17 >35 then 'rede'
    when column19 > 8 then 'greenf'
    when column19 < 8 then 'redf'
    else ''
    end

    thanks for all your help btw

  6. myDBR Team, Key Master

    Your rowclass returns just one rowstyle. You should return style for each of the columns you like to have color ("reda redb greenc greend rede redf").

    --
    myDBR


Reply

You must log in to post.