<?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: Subtract value from first occurence of data in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111084#M17314</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;and what about using firstsortedvalue() to retrieve the 1st value based on date ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 05 Jul 2018 07:13:39 GMT</pubDate>
    <dc:creator>olivierrobin</dc:creator>
    <dc:date>2018-07-05T07:13:39Z</dc:date>
    <item>
      <title>Subtract value from first occurence of data</title>
      <link>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111083#M17313</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working with a graph of Order Date (x axis) and cumulative order value (y axis). This is for a monthly recurring subscription service. I need to subtract a cost (the CPA) from the &lt;STRONG&gt;first&lt;/STRONG&gt; instance of the customer ID appearing in the data.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My current method subtracts the CPA from &lt;STRONG&gt;every&lt;/STRONG&gt; instance of the customer ID, rather than just the first instance. There should only be 1 CPA per customer, so sum(CPA) = [CPA]* Distinct ( Count ( customer_id ) )&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is my current expression:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;rangesum ( above ( ( sum ( [OrderValue]) - ( [CPA]* Distinct ( Count ( customer_id ) ) ) ) ,0,rowno()))&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The X-axis is OrderDate, which for a subscription service means the customer ID appears multiple times (as there is 1 order every month).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For example, if CPA = 5&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;TABLE border="1" class="jiveBorder" style="border: 1px solid rgb(0, 0, 0); width: 100%;"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;&lt;STRONG&gt;OrderDate&lt;BR /&gt;&lt;/STRONG&gt;&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;OrderValue&lt;/TH&gt;&lt;TH style="text-align: center; background-color: #6690bc; color: #ffffff; padding: 2px;" valign="middle"&gt;Actual Order Value (the one I want to display)&lt;/TH&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;01/01/2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;15&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;04/02/2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;03/03/2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD style="padding: 2px;"&gt;05/04/2018&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;TD style="padding: 2px;"&gt;20&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;etc&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Weirdly, we don't have order number in the data, so I can't simply use {$&amp;lt;[OrderNumber]={'1'}&amp;gt;}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 04 Jul 2018 16:08:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111083#M17313</guid>
      <dc:creator>jamestaylor52</dc:creator>
      <dc:date>2018-07-04T16:08:32Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract value from first occurence of data</title>
      <link>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111084#M17314</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hello&lt;/P&gt;&lt;P&gt;and what about using firstsortedvalue() to retrieve the 1st value based on date ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jul 2018 07:13:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111084#M17314</guid>
      <dc:creator>olivierrobin</dc:creator>
      <dc:date>2018-07-05T07:13:39Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract value from first occurence of data</title>
      <link>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111085#M17315</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks Olivier.&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;As my graph charts by month, when I've tried firstsortedvalue() it has performed it on every month. So it leaves me as the same result as &lt;/SPAN&gt;&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 12px;"&gt;Distinct ( Count ( customer_id ) ).&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jul 2018 09:26:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111085#M17315</guid>
      <dc:creator>jamestaylor52</dc:creator>
      <dc:date>2018-07-05T09:26:35Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract value from first occurence of data</title>
      <link>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111086#M17316</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;To update, I believe I've worked it out using aggr() function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;(count(aggr(min([order_date.autoCalendar.YearMonth]),customerID) returns a value of 1 at the first month the customer ID appears. This works perfectly!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 05 Jul 2018 11:09:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Subtract-value-from-first-occurence-of-data/m-p/111086#M17316</guid>
      <dc:creator>jamestaylor52</dc:creator>
      <dc:date>2018-07-05T11:09:02Z</dc:date>
    </item>
  </channel>
</rss>

