<?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 Re: Stacked bar with 2 dimensions and 2 expression in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198116#M880606</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used script changes too, but without any calculations in the script if that matters at all. The sum(if()) means low performance on large data sets, but that shouldn't be an issue if these are just monthly totals by department. I set up a field that has all departments plus 'Excess Demand'. Then I reference that field when deciding what to add up for that "department".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DemandVsSupply:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD text(fieldvalue('Department',recno())) as Department2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE fieldvaluecount('Department')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CONCATENATE (DemandVsSupply)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD 'Excess Demand' as Department2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if(Department2='Excess Demand',sum(Demand)-sum(Supply),sum(if(Department=Department2,Supply)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You CAN do it without that script change with a valuelist replacing Department2, but I wouldn't. Still, if you really, really don't want to change script, I'll include that approach as well. Everywhere the above uses Department2, use this instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;valuelist($(=chr(39)&amp;amp;concat(distinct Department,chr(39)&amp;amp;','&amp;amp;chr(39))&amp;amp;chr(39)&amp;amp;','&amp;amp;chr(39)&amp;amp;'Excess Demand'&amp;amp;chr(39)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="141264" alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/141264_Capture.PNG" style="width: 620px; height: 253px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 19 Oct 2016 18:56:38 GMT</pubDate>
    <dc:creator>johnw</dc:creator>
    <dc:date>2016-10-19T18:56:38Z</dc:date>
    <item>
      <title>Stacked bar with 2 dimensions and 2 expression</title>
      <link>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198114#M880604</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I want to build a stacked bar chart, which shows Demand vs Supply. Demand will be the overall number for a month but supply will be broken down by departments per month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I need to show a stacked bar chart per month, where the supply is broken down by department and the difference between the overall demand and overall supply at the top of it.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am attaching the sample data file and sample qvw. I am able to achieve part of it using valuelist but the demand and supply are being broken into two different bars (see chart named Demand vs Supply). Is there anyway I can stack the gray bar on top of the color bars?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198114#M880604</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Stacked bar with 2 dimensions and 2 expression</title>
      <link>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198115#M880605</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was able to achieve the expected output by doing some changes on the script. I was not able to achieve this without changes in the script. If any of you were able to achieve it without changes in script please post your ideas.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 17 Oct 2016 17:54:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198115#M880605</guid>
      <dc:creator />
      <dc:date>2016-10-17T17:54:36Z</dc:date>
    </item>
    <item>
      <title>Re: Stacked bar with 2 dimensions and 2 expression</title>
      <link>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198116#M880606</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I used script changes too, but without any calculations in the script if that matters at all. The sum(if()) means low performance on large data sets, but that shouldn't be an issue if these are just monthly totals by department. I set up a field that has all departments plus 'Excess Demand'. Then I reference that field when deciding what to add up for that "department".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;DemandVsSupply:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD text(fieldvalue('Department',recno())) as Department2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE fieldvaluecount('Department')&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;CONCATENATE (DemandVsSupply)&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;LOAD 'Excess Demand' as Department2&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;AUTOGENERATE 1&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if(Department2='Excess Demand',sum(Demand)-sum(Supply),sum(if(Department=Department2,Supply)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You CAN do it without that script change with a valuelist replacing Department2, but I wouldn't. Still, if you really, really don't want to change script, I'll include that approach as well. Everywhere the above uses Department2, use this instead.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;valuelist($(=chr(39)&amp;amp;concat(distinct Department,chr(39)&amp;amp;','&amp;amp;chr(39))&amp;amp;chr(39)&amp;amp;','&amp;amp;chr(39)&amp;amp;'Excess Demand'&amp;amp;chr(39)))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG __jive_id="141264" alt="Capture.PNG" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/141264_Capture.PNG" style="width: 620px; height: 253px;" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 18:56:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198116#M880606</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2016-10-19T18:56:38Z</dc:date>
    </item>
    <item>
      <title>Re: Stacked bar with 2 dimensions and 2 expression</title>
      <link>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198117#M880607</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Your first solution worked like a charm! Thanks a lot.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 19 Oct 2016 19:13:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198117#M880607</guid>
      <dc:creator />
      <dc:date>2016-10-19T19:13:00Z</dc:date>
    </item>
    <item>
      <title>Re: Stacked bar with 2 dimensions and 2 expression</title>
      <link>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198118#M880608</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here's another approach with higher performance than the previous two without doing any calculation in script. I concatenate the two tables using 'Excess Demand' as the Department for demand. Then the chart has this expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: courier new,courier;"&gt;if(Department='Excess Demand',sum(Demand)-sum(total &amp;lt;YearMonth&amp;gt; Supply),sum(Supply))&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 20 Oct 2016 16:20:51 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Stacked-bar-with-2-dimensions-and-2-expression/m-p/1198118#M880608</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2016-10-20T16:20:51Z</dc:date>
    </item>
  </channel>
</rss>

