<?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: Percentage in Graph - Expression problem in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049105#M929965</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: line-through;"&gt;Sum({&amp;lt;ORDER_ON_TIME = {'On Time'}&amp;gt;}[On Time])/&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG style="text-decoration: line-through;"&gt;Sum([On Time])&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;STRONG style="font-size: 13.3333px;"&gt;Sum({&amp;lt;ORDER_ON_TIME = {'On Time'}&amp;gt;}[On Time])/&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;Sum(&lt;STRONG style="font-size: 13.3333px;"&gt;{&amp;lt;ORDER_ON_TIME = {'Late'}&amp;gt;}&lt;/STRONG&gt;[On Time])&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 22 Mar 2016 20:22:42 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2016-03-22T20:22:42Z</dc:date>
    <item>
      <title>Percentage in Graph - Expression problem</title>
      <link>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049104#M929964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a table with the following fields:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Sales_Order_No - This holds Sales Order Numbers&lt;/LI&gt;&lt;LI&gt;Month - This holds the Month the Sales Order was created&lt;/LI&gt;&lt;LI&gt;Year - This holds the Year the Sales Order was created.&lt;/LI&gt;&lt;LI&gt;Order_On_Time - This field holds one of two values....Either 'On Time' or 'Late' and describes whether or not the Order reached the Customer on time or not.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am trying to create a graph by month showing a percentage of 'On Time' Orders only but I am struggling to get the expression correct. The base data looks like this (Simple chart):-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-4" src="https://community.qlik.com/legacyfs/online/119011_pastedImage_4.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;P&gt;I have managed to 'hide' the 'Late' Orders and see the 'On Time' totals only by using this:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;match&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;('On Time',&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/119006_pastedImage_0.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If I try to divide this by the Total Orders to get the percentage, I get odd results:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;match&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;('On Time',&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;gives me nothing:-&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;IMG class="jive-image image-2" src="https://community.qlik.com/legacyfs/online/119008_pastedImage_2.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;match&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;('On Time',&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;match&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;('On Time',&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) + &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;sum&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;match&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;('Late',&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)) &lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;gives me &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;IMG class="jive-image image-3" src="https://community.qlik.com/legacyfs/online/119010_pastedImage_1.png" style="max-height: 900px; max-width: 1200px;" /&gt;&lt;/P&gt;&lt;P&gt;I'd like to see what percentage were 'On Time' each month so I can see if our 'On Time Delivery' to the customer is improving over time.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Eg,&lt;/P&gt;&lt;P&gt;Jan would be 728 / (728+1941) = 0.27 = 27%&lt;/P&gt;&lt;P&gt;Feb would be 788 / (788 + 1812) = 0.30 = 30%&lt;/P&gt;&lt;P&gt;Mar would be 978 / (978 + 2154) = 0.31 = 31 %&lt;/P&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Jason&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/Percentage-in-Graph-Expression-problem/m-p/1049104#M929964</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage in Graph - Expression problem</title>
      <link>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049105#M929965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Can you try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG style="text-decoration: line-through;"&gt;Sum({&amp;lt;ORDER_ON_TIME = {'On Time'}&amp;gt;}[On Time])/&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG style="text-decoration: line-through;"&gt;Sum([On Time])&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;STRONG style="font-size: 13.3333px;"&gt;Sum({&amp;lt;ORDER_ON_TIME = {'On Time'}&amp;gt;}[On Time])/&lt;/STRONG&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;STRONG&gt;Sum(&lt;STRONG style="font-size: 13.3333px;"&gt;{&amp;lt;ORDER_ON_TIME = {'Late'}&amp;gt;}&lt;/STRONG&gt;[On Time])&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2016 20:22:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049105#M929965</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2016-03-22T20:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage in Graph - Expression problem</title>
      <link>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049106#M929966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sum(match('On Time',ORDER_ON_TIME)) shouldn't give you a positive sum. It should give you a negative sum. The match() should return -1 if the order is on time, 0 if it isn't.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum(ORDER_ON_TIME) gives you nothing because you're telling it to sum a text field. You can't sum a text field and get any logical result, so it gives you null, and that null propogates to the overall expression.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Sum(match('On Time',ORDER_ON_TIME)) / sum(match('On Time',ORDER_ON_TIME)) + sum(match('Late',ORDER_ON_TIME)) is missing a set of parentheses after the / and at the end. You're doing the division first, so that part would return 1. Then the second part must for some reason be returning 0. Maybe you selected the value 'On Time', in which case there would be no matching late orders. Anyway, you could make something along those lines work, but it would be inefficient.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Set analysis is more efficient. This version is a strict percentage ignoring your selections in the ORDER_ON_TIME field:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;count({&amp;lt;ORDER_ON_TIME={'On Time'}&amp;gt;} distinct Sales_Order_No)/count({&amp;lt;ORDER_ON_TIME=&amp;gt;} distinct Sales_Order_No)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This one gives you the percentage of on time orders in the currently-matching orders. So if you selected on time, you'd see 100%. If you selected late, you'd see 0%.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;count({&amp;lt;ORDER_ON_TIME*={'On Time'}&amp;gt;} distinct Sales_Order_No)/count(distinct Sales_Order_No)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another approach would be to add counter fields to your table in the script.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;,if(ORDER_ON_TIME='On Time',1) as On_Time_Count&lt;BR /&gt;,1 as All_Count&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And in your chart:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;sum(On_Time_Count)/sum(All_Count)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 22 Mar 2016 20:48:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049106#M929966</guid>
      <dc:creator>johnw</dc:creator>
      <dc:date>2016-03-22T20:48:07Z</dc:date>
    </item>
    <item>
      <title>Re: Percentage in Graph - Expression problem</title>
      <link>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049107#M929967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for your help guys. Your comments have helped me find the solution:-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;=&lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;({&amp;lt;&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;={'On Time'}&amp;gt;}&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;Sales_Order_No&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;) / &lt;/SPAN&gt;&lt;SPAN style="color: #0000ff; font-size: 8pt;"&gt;count&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;(&lt;/SPAN&gt;&lt;SPAN style="color: #800000; font-size: 8pt;"&gt;ORDER_ON_TIME&lt;/SPAN&gt;&lt;SPAN style="font-size: 8pt;"&gt;)&lt;BR /&gt; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;This works perfectly. I had 'ORDER_ON_TIME' set as a Dimension too which was causing me headaches. Removing this and using the command above has solved it.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Jason&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 23 Mar 2016 09:10:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Percentage-in-Graph-Expression-problem/m-p/1049107#M929967</guid>
      <dc:creator />
      <dc:date>2016-03-23T09:10:01Z</dc:date>
    </item>
  </channel>
</rss>

