<?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 Problem with ApplyMap and dates in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Problem-with-ApplyMap-and-dates/m-p/808302#M285326</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'm having trouble getting ApplyMap to work with dates (stored as TIMESTAMP in Oracle). I have built a calendar as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265070222906700" jivemacro_uid="_14265070222906700"&gt;
&lt;P&gt;TempCalendar:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Date($(vMinInst) + RowNo() - 1) as TempDate&lt;/P&gt;
&lt;P&gt;&amp;nbsp; AutoGenerate $(vMaxInst) - $(vMinInst) + 1;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Calendar:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TempDate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as TimeId&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Day(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Day&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , DayName(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp; as DayDesc&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Week(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Week&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , WeekName(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp; as WeekDesc&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Month(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Month&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Year(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Year&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , QuarterName(TempDate) as Quarter&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Resident TempCalendar;&lt;/P&gt;




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then build a mapping table based on Calendar:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265070353631434" jivemacro_uid="_14265070353631434"&gt;
&lt;P&gt;Map_Time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Mapping&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; TimeId, AutoNumber(TimeId) as AutoTimeId&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Resident Calendar;&lt;/P&gt;




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I do the following, I get NONE instead of the auto-numbered value I expect:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265070720991251" jivemacro_uid="_14265070720991251"&gt;
&lt;P&gt;ApplyMap('Map_Time',Date(SOME_TIMESTAMP_FROM_ORACLE),'NONE')&lt;/P&gt;




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ApplyMap function is applied to a table that is already in QlikView, so the issue is &lt;EM&gt;not&lt;/EM&gt; that Date is unknown in Oracle; this would cause Oracle to spit out an error anyway. The table is loaded with a resident load &lt;EM&gt;after&lt;/EM&gt; I have imported the relevant data from the DB:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265075827425216" jivemacro_uid="_14265075827425216" modifiedtitle="true"&gt;
&lt;P&gt;TempData:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SELECT * FROM some_table;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;MyTab:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ApplyMap(...)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt; , ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Resident TempData;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a similar technique with a mapping table and ApplyMap on other fields and it works like a charm. However, with the date field from the database the mapping table seems to yield nothing. Removing AutoNumber yields the same (disappointing) result.&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;Message was edited by: Christian Hellström - added clarification on load.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 16 Mar 2015 12:02:44 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-03-16T12:02:44Z</dc:date>
    <item>
      <title>Problem with ApplyMap and dates</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-ApplyMap-and-dates/m-p/808302#M285326</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'm having trouble getting ApplyMap to work with dates (stored as TIMESTAMP in Oracle). I have built a calendar as follows:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265070222906700" jivemacro_uid="_14265070222906700"&gt;
&lt;P&gt;TempCalendar:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Date($(vMinInst) + RowNo() - 1) as TempDate&lt;/P&gt;
&lt;P&gt;&amp;nbsp; AutoGenerate $(vMaxInst) - $(vMinInst) + 1;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Calendar:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; TempDate&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as TimeId&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Day(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Day&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , DayName(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp; as DayDesc&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Week(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Week&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , WeekName(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp; as WeekDesc&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Month(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Month&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , Year(TempDate)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; as Year&lt;/P&gt;
&lt;P&gt;&amp;nbsp; , QuarterName(TempDate) as Quarter&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Resident TempCalendar;&lt;/P&gt;




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then build a mapping table based on Calendar:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265070353631434" jivemacro_uid="_14265070353631434"&gt;
&lt;P&gt;Map_Time:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Mapping&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&amp;nbsp; TimeId, AutoNumber(TimeId) as AutoTimeId&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Resident Calendar;&lt;/P&gt;




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;However, when I do the following, I get NONE instead of the auto-numbered value I expect:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265070720991251" jivemacro_uid="_14265070720991251"&gt;
&lt;P&gt;ApplyMap('Map_Time',Date(SOME_TIMESTAMP_FROM_ORACLE),'NONE')&lt;/P&gt;




&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The ApplyMap function is applied to a table that is already in QlikView, so the issue is &lt;EM&gt;not&lt;/EM&gt; that Date is unknown in Oracle; this would cause Oracle to spit out an error anyway. The table is loaded with a resident load &lt;EM&gt;after&lt;/EM&gt; I have imported the relevant data from the DB:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE __default_attr="plain" __jive_macro_name="code" class="jive_text_macro jive_macro_code _jivemacro_uid_14265075827425216" jivemacro_uid="_14265075827425216" modifiedtitle="true"&gt;
&lt;P&gt;TempData:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; SELECT * FROM some_table;&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;MyTab:&lt;/P&gt;
&lt;P&gt;&amp;nbsp; LOAD&lt;/P&gt;
&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ApplyMap(...)&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt; , ...&lt;/P&gt;
&lt;P&gt;&amp;nbsp; Resident TempData;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am using a similar technique with a mapping table and ApplyMap on other fields and it works like a charm. However, with the date field from the database the mapping table seems to yield nothing. Removing AutoNumber yields the same (disappointing) result.&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;Message was edited by: Christian Hellström - added clarification on load.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 12:02:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-ApplyMap-and-dates/m-p/808302#M285326</guid>
      <dc:creator />
      <dc:date>2015-03-16T12:02:44Z</dc:date>
    </item>
    <item>
      <title>Re: Problem with ApplyMap and dates</title>
      <link>https://community.qlik.com/t5/QlikView/Problem-with-ApplyMap-and-dates/m-p/808303#M285327</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I know it's bad to answer your own questions but it seems I have figured it out: Date is a &lt;EM&gt;formatting&lt;/EM&gt; function that causes different times during the same day to be displayed the same but stored differently (numerically). So, when QlikView looks up the (numerical) value it finds no match because the mapping table has other entries after the decimal point.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The solution is to use Date(DayStart(...)) instead of just Date(...). This way, the output &lt;EM&gt;and&lt;/EM&gt; the storage are exactly the same. Date strips off the time part, which is what I'm not interested in anyway.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Silly me.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 16 Mar 2015 14:09:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Problem-with-ApplyMap-and-dates/m-p/808303#M285327</guid>
      <dc:creator />
      <dc:date>2015-03-16T14:09:47Z</dc:date>
    </item>
  </channel>
</rss>

