<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Expression Color Change based on Set Analysis &amp;gt; in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Expression-Color-Change-based-on-Set-Analysis-gt/m-p/325474#M581812</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need some help with an express I'm trying to use to change the color of a bar chart. I have a bar chart object with one dimension (Year) and three expressions (Expenses, Deposits and Difference). I'm using set analysis in these to calculate to the totals:&lt;/P&gt;&lt;P&gt;1&lt;SPAN style="color: #333333;"&gt;. Expenses: SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;2. Deposits: SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;3. Difference: SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]) - SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Then for the third bar chart element (Difference) I'm trying to change the color based on whether or not the difference is a positive or negative one (i.e. green or red). Here is what I'm using: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;IF(SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]) &amp;gt; SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]), Red(), IF(SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]) &amp;gt; SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]), Green(), Yellow()))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is that it is green (always). Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 16 Nov 2011 21:34:34 GMT</pubDate>
    <dc:creator>jcampbell</dc:creator>
    <dc:date>2011-11-16T21:34:34Z</dc:date>
    <item>
      <title>Expression Color Change based on Set Analysis &gt;</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-Color-Change-based-on-Set-Analysis-gt/m-p/325474#M581812</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I need some help with an express I'm trying to use to change the color of a bar chart. I have a bar chart object with one dimension (Year) and three expressions (Expenses, Deposits and Difference). I'm using set analysis in these to calculate to the totals:&lt;/P&gt;&lt;P&gt;1&lt;SPAN style="color: #333333;"&gt;. Expenses: SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;2. Deposits: SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #333333;"&gt;3. Difference: SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]) - SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;Then for the third bar chart element (Difference) I'm trying to change the color based on whether or not the difference is a positive or negative one (i.e. green or red). Here is what I'm using: &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #000000;"&gt;IF(SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]) &amp;gt; SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]), Red(), IF(SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]) &amp;gt; SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]), Green(), Yellow()))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The result is that it is green (always). Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Josh&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 21:34:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-Color-Change-based-on-Set-Analysis-gt/m-p/325474#M581812</guid>
      <dc:creator>jcampbell</dc:creator>
      <dc:date>2011-11-16T21:34:34Z</dc:date>
    </item>
    <item>
      <title>Expression Color Change based on Set Analysis &gt;</title>
      <link>https://community.qlik.com/t5/QlikView/Expression-Color-Change-based-on-Set-Analysis-gt/m-p/325475#M581813</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The expression looks okay, where do you have it applied, against the dimension or the expression?&amp;nbsp; This will give you different results.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can you post up an example with dummy data showing it not working?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The expression could be slightly simplified by doing:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if (SUM({$&amp;lt;[Category]={'Deposit'}&amp;gt;}[Amount]) - SUM({$&amp;lt;[Category]={'Expense'}&amp;gt;}[Amount]) &amp;gt; 0, Green(), Red())&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Obviously that doesn't do your exactly equal - but if that was the situation then there would be no bar to colour.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What can make things simpler and more efficient at display time is to have at least two value fields, created in yoru load script, thusly:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp; [...]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; Category,&lt;/P&gt;&lt;P&gt;&amp;nbsp; Amount,&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(Category = 'Deposit', Amount, 0) as [Deposit Amount],&lt;/P&gt;&lt;P&gt;&amp;nbsp; if(Category = 'Expense', Amount * -1, 0) as [Expense Amount],&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp; [...]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;That way you can do away with the set analysis and just sum the two fields.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another point, is that the default colours are not always great, you are better specifying rgb values, eg. &lt;STRONG&gt;rgb(200, 255, 200)&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Hope that helps,&lt;/P&gt;&lt;P&gt;Steve&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 16 Nov 2011 21:45:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Expression-Color-Change-based-on-Set-Analysis-gt/m-p/325475#M581813</guid>
      <dc:creator>stevedark</dc:creator>
      <dc:date>2011-11-16T21:45:47Z</dc:date>
    </item>
  </channel>
</rss>

