<?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: Using FirstSortedValue() as Dimension of a Chart in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-FirstSortedValue-as-Dimension-of-a-Chart/m-p/460875#M569964</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried to get by for now by doing this in the LOAD SCRIPT. Ideally, I need to do it as a dimension of a chart, but for now, creating the value in the LOAD will work. This is my attempt and I cannot get it to work. Any ideas on this? I don't think IntervalMatch will work for me in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// GOAL: TO FIND MOST RECENT PURCHASE OF SKU [BBB] PRIOR TO EACH MAILING&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;mailing: load CUSTOMER, Date(Date#(MAIL_DATE, 'MM/DD/YYYY'),'$(DateFormat)') AS MAIL_DATE inline&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[CUSTOMER, MAIL_DATE,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;101, 05/15/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;102, 02/13/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;102, 11/22/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sales: load CUSTOMER, SKU, Date(Date#(ORDER_DATE, 'MM/DD/YYYY'),'$(DateFormat)') AS ORDER_DATE inline&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[CUSTOMER, SKU, ORDER_DATE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;101, BBB, 01/19/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;101, AAA, 03/30/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;102, BBB, 04/15/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;LEFT JOIN (mailing) LOAD CUSTOMER, FirstSortedValue(ORDER_DATE, -IF(ORDER_DATE&amp;lt;MAIL_DATE and SKU='BBB',TRAN_PROCDATE)) AS LAST_BBB_ORDER;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// RESULTING mailing TABLE SHOULD LOOK LIKE THIS:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;//&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// CUSTOMER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAIL_DATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LAST_BBB_ORDER&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// 101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 05/15/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/19/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// 102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/13/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// 102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11/22/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 04/15/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;//&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I obtain LAST_BBB_ORDER?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 02 Oct 2012 19:12:17 GMT</pubDate>
    <dc:creator>Rich-HHE</dc:creator>
    <dc:date>2012-10-02T19:12:17Z</dc:date>
    <item>
      <title>Using FirstSortedValue() as Dimension of a Chart</title>
      <link>https://community.qlik.com/t5/QlikView/Using-FirstSortedValue-as-Dimension-of-a-Chart/m-p/460874#M569963</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello, I need to plot response rate (orders per piece mailed) as a function of "Customer Age" at the time of the mailing. "Customer Age" is defined in this case as how many months &lt;STRONG&gt;since the last order &lt;/STRONG&gt;&lt;STRONG&gt;at the time of the mailing&lt;/STRONG&gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I add the following expression to a pivot chart as an &lt;STRONG&gt;expression&lt;/STRONG&gt;, I get the proper values. When I add this expression as a &lt;STRONG&gt;dimension&lt;/STRONG&gt; of a chart, it says &lt;SPAN style="color: #800000;"&gt;&lt;STRONG&gt;// Error in calculated dimension&lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here is the expression I would like as a dimension of the chart:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000;"&gt;&lt;STRONG style="font-family: 'courier new', courier;"&gt;=FLOOR((BULK_MAIL_DROP_DATE-FirstSortedValue(TRAN_PROCDATE, -IF(TRAN_PROCDATE&amp;lt;BULK_MAIL_DROP_DATE and TRAN_AMOUNT&amp;gt;0 and ITEM_PROD_GRP_MAJ='ORD',TRAN_PROCDATE)))/30)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think there is a logical disconnect that my mind cannot see. Does anyone know what it is and/or how I would accomplish this task?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 17:28:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-FirstSortedValue-as-Dimension-of-a-Chart/m-p/460874#M569963</guid>
      <dc:creator>Rich-HHE</dc:creator>
      <dc:date>2012-10-02T17:28:31Z</dc:date>
    </item>
    <item>
      <title>Re: Using FirstSortedValue() as Dimension of a Chart</title>
      <link>https://community.qlik.com/t5/QlikView/Using-FirstSortedValue-as-Dimension-of-a-Chart/m-p/460875#M569964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I've tried to get by for now by doing this in the LOAD SCRIPT. Ideally, I need to do it as a dimension of a chart, but for now, creating the value in the LOAD will work. This is my attempt and I cannot get it to work. Any ideas on this? I don't think IntervalMatch will work for me in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// GOAL: TO FIND MOST RECENT PURCHASE OF SKU [BBB] PRIOR TO EACH MAILING&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;mailing: load CUSTOMER, Date(Date#(MAIL_DATE, 'MM/DD/YYYY'),'$(DateFormat)') AS MAIL_DATE inline&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[CUSTOMER, MAIL_DATE,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;101, 05/15/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;102, 02/13/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;102, 11/22/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;sales: load CUSTOMER, SKU, Date(Date#(ORDER_DATE, 'MM/DD/YYYY'),'$(DateFormat)') AS ORDER_DATE inline&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;[CUSTOMER, SKU, ORDER_DATE&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;101, BBB, 01/19/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;101, AAA, 03/30/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;102, BBB, 04/15/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;];&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;LEFT JOIN (mailing) LOAD CUSTOMER, FirstSortedValue(ORDER_DATE, -IF(ORDER_DATE&amp;lt;MAIL_DATE and SKU='BBB',TRAN_PROCDATE)) AS LAST_BBB_ORDER;&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// RESULTING mailing TABLE SHOULD LOOK LIKE THIS:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;//&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// CUSTOMER&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MAIL_DATE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LAST_BBB_ORDER&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// 101&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 05/15/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 01/19/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// 102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 02/13/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;// 102&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11/22/2012&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 04/15/2012&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;//&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I obtain LAST_BBB_ORDER?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;BR /&gt;Rich&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 02 Oct 2012 19:12:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-FirstSortedValue-as-Dimension-of-a-Chart/m-p/460875#M569964</guid>
      <dc:creator>Rich-HHE</dc:creator>
      <dc:date>2012-10-02T19:12:17Z</dc:date>
    </item>
    <item>
      <title>Re: Using FirstSortedValue() as Dimension of a Chart</title>
      <link>https://community.qlik.com/t5/QlikView/Using-FirstSortedValue-as-Dimension-of-a-Chart/m-p/460876#M569965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I figured it out in the chart dimension. I needed to AGGREGATE on the Customer ID. Please note that all the calculations that are to be made on a given customer are done inside the Aggr() function and the Aggr() function's second parameter (what to aggregate on) is CUSTOMER_ID. Also note, I switched to MAX() instead of FirstSortedValue() because it was simpler for what I was doing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="color: #008000; font-family: 'courier new', courier;"&gt;&lt;STRONG&gt;=FLOOR((Aggr(BULK_MAIL_DROP_DATE-MAX(IF(TRAN_PROCDATE&amp;lt;BULK_MAIL_DROP_DATE and TRAN_AMOUNT&amp;gt;0 and ITEM_PROD_GRP_MAJ='ORD',TRAN_PROCDATE)),CUSTOMER_ID))/30)&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Rich&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt;"&gt;&lt;STRONG&gt;IMPORTANT NOTE: This only works when I select one mailing. When I select multiple mailings (especially multiple mailings that mail to the same customers, I get funky results. I'm still trying to figure out how to aggregate appropriately when a customer is in more than one mailing.&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 03 Oct 2012 13:50:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-FirstSortedValue-as-Dimension-of-a-Chart/m-p/460876#M569965</guid>
      <dc:creator>Rich-HHE</dc:creator>
      <dc:date>2012-10-03T13:50:24Z</dc:date>
    </item>
  </channel>
</rss>

