<?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 Set Analysis: Percent of Total not working correctly in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Percent-of-Total-not-working-correctly/m-p/26644#M772290</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having trouble getting my set expression to display percent of total correctly. In my line chart, I have it set to display a rolling four year period (e.g., each of the last 4 years based upon the year selected by the user), using the following two defined variables and the set expression:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vMinYear =&amp;nbsp; if(GetSelectedCount(Year)=1,AddYears(Max(date),-4))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vYearSelected&amp;nbsp; = if(GetSelectedCount(Year)=1,Max(date))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The above set gives me the correct sums (i.e., sum of responses) for the year(s) in question. What I need, though, is the &lt;STRONG&gt;&lt;EM style="text-decoration: underline;"&gt;percent of total&lt;/EM&gt;&lt;/STRONG&gt; for those years. Some my question is: what would I use as the denominator in this set to get the correct % of Total:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) /&lt;STRONG&gt; ?????&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Below are some attempts &lt;EM&gt;that didn't work&lt;/EM&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) / &lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;Sum(TOTAL Responses) &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --- &lt;/STRONG&gt;it&lt;STRONG&gt; &lt;/STRONG&gt;gives the correct % of Total only for the last year selected, &lt;EM style="text-decoration: underline;"&gt;but not for any of the earlier years.&lt;/EM&gt; (e.g., if user selects 2017, correct % of total is displayed for 2017, but not for 2016, 2015, or 2014). Through some digging I discovered that Sum(TOTAL Responses) is returning total only for the &lt;EM&gt;&lt;SPAN style="text-decoration: underline;"&gt;currently &lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline;"&gt;selected year&lt;/SPAN&gt;&lt;/EM&gt;, so it won't work as the denominator of the earlier years (whose base totals are different)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) / &lt;STRONG&gt;Sum(TOTAL {$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---&lt;/STRONG&gt;gives the incorrect % of total for all years. In this case, the set in the denominator is returning the total &lt;EM style="text-decoration: underline;"&gt;for all 4 years&lt;/EM&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;For illustration purposes, if the totals for Year4 (selected year) is 20, Year3 is 30, Year2 is 30, and Year1&amp;nbsp; is 50...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp; ... &lt;STRONG style="font-size: 13.3333px;"&gt;Sum(TOTAL Responses) &lt;/STRONG&gt;is using 20 as the denominator, which is incorrect&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp; ...&lt;STRONG style="font-size: 13.3333px;"&gt;Sum(TOTAL {$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) &lt;/STRONG&gt;is using 130 as the denominator, which isn't correct&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I'd need the set to divide the sum of each year by its respective total (e.g., sum Year4 / 20, and sum Year3 / 30, etc).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Any suggestions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;John &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
    <dc:creator>jchambers123</dc:creator>
    <dc:date>2020-11-25T16:16:04Z</dc:date>
    <item>
      <title>Set Analysis: Percent of Total not working correctly</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Percent-of-Total-not-working-correctly/m-p/26644#M772290</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello community,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I'm having trouble getting my set expression to display percent of total correctly. In my line chart, I have it set to display a rolling four year period (e.g., each of the last 4 years based upon the year selected by the user), using the following two defined variables and the set expression:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vMinYear =&amp;nbsp; if(GetSelectedCount(Year)=1,AddYears(Max(date),-4))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; vYearSelected&amp;nbsp; = if(GetSelectedCount(Year)=1,Max(date))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;The above set gives me the correct sums (i.e., sum of responses) for the year(s) in question. What I need, though, is the &lt;STRONG&gt;&lt;EM style="text-decoration: underline;"&gt;percent of total&lt;/EM&gt;&lt;/STRONG&gt; for those years. Some my question is: what would I use as the denominator in this set to get the correct % of Total:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="font-size: 10pt;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) /&lt;STRONG&gt; ?????&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;Below are some attempts &lt;EM&gt;that didn't work&lt;/EM&gt;:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) / &lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;Sum(TOTAL Responses) &lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; --- &lt;/STRONG&gt;it&lt;STRONG&gt; &lt;/STRONG&gt;gives the correct % of Total only for the last year selected, &lt;EM style="text-decoration: underline;"&gt;but not for any of the earlier years.&lt;/EM&gt; (e.g., if user selects 2017, correct % of total is displayed for 2017, but not for 2016, 2015, or 2014). Through some digging I discovered that Sum(TOTAL Responses) is returning total only for the &lt;EM&gt;&lt;SPAN style="text-decoration: underline;"&gt;currently &lt;/SPAN&gt;&lt;SPAN style="text-decoration: underline;"&gt;selected year&lt;/SPAN&gt;&lt;/EM&gt;, so it won't work as the denominator of the earlier years (whose base totals are different)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;=Sum({$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) / &lt;STRONG&gt;Sum(TOTAL {$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---&lt;/STRONG&gt;gives the incorrect % of total for all years. In this case, the set in the denominator is returning the total &lt;EM style="text-decoration: underline;"&gt;for all 4 years&lt;/EM&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;For illustration purposes, if the totals for Year4 (selected year) is 20, Year3 is 30, Year2 is 30, and Year1&amp;nbsp; is 50...&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp; ... &lt;STRONG style="font-size: 13.3333px;"&gt;Sum(TOTAL Responses) &lt;/STRONG&gt;is using 20 as the denominator, which is incorrect&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp; ...&lt;STRONG style="font-size: 13.3333px;"&gt;Sum(TOTAL {$&amp;lt;Year=,date= {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;}Responses) &lt;/STRONG&gt;is using 130 as the denominator, which isn't correct&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;I'd need the set to divide the sum of each year by its respective total (e.g., sum Year4 / 20, and sum Year3 / 30, etc).&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Any suggestions?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;Thanks in advance,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;John &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;&lt;BR /&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&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/Set-Analysis-Percent-of-Total-not-working-correctly/m-p/26644#M772290</guid>
      <dc:creator>jchambers123</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis: Percent of Total not working correctly</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Percent-of-Total-not-working-correctly/m-p/26645#M772291</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;=Sum({$&amp;lt;Year, date = {'&amp;gt;$(vMinYear)&amp;lt;=$(vYearSelected)'}&amp;gt;} Responses) / Sum(TOTAL &lt;SPAN style="color: #ff0000;"&gt;&amp;lt;Year&amp;gt;&lt;/SPAN&gt; {$&amp;lt;Year, date = {'&amp;gt;$(vMinYear)&amp;nbsp; &amp;lt;=$(vYearSelected)'}&amp;gt;} Responses)&lt;/STRONG&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 17:25:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-Percent-of-Total-not-working-correctly/m-p/26645#M772291</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-05-29T17:25:17Z</dc:date>
    </item>
    <item>
      <title>Re: Set Analysis: Percent of Total not working correctly</title>
      <link>https://community.qlik.com/t5/QlikView/Set-Analysis-Percent-of-Total-not-working-correctly/m-p/26646#M772292</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;It worked, Sunny. Thanks so much!&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 29 May 2018 18:25:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Set-Analysis-Percent-of-Total-not-working-correctly/m-p/26646#M772292</guid>
      <dc:creator>jchambers123</dc:creator>
      <dc:date>2018-05-29T18:25:44Z</dc:date>
    </item>
  </channel>
</rss>

