<?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: Selecting a value based on a time selection in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093976#M1224202</link>
    <description>&lt;P&gt;I wanted to clarify something to make it clearer on where i am reading my data from&lt;/P&gt;
&lt;P&gt;My load statement that uses the applymap function is reading from a sql view&lt;/P&gt;
&lt;P&gt;Load&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fields&lt;/P&gt;
&lt;P&gt;APPLYMAP('MapAgency',[Source],null()) as [Agency Type]&lt;/P&gt;
&lt;P&gt;FROM sql view&lt;/P&gt;
&lt;P&gt;The Source value mentioned in the apply map statement is the Agency Name from my sql view and this then goes to the mapping table and finds the agency name and then returns either NC or C and stores this as [Agency Type]. I have used an excel mapping table as the system that I am reading the data from only stores the AgencyName.&lt;/P&gt;
&lt;P&gt;The mapping table should read from the example.xlsx file&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MapAgency:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mapping&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LOAD AgencyName, Status&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM ...example.xlsx&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Would the suggestion above work as i am still trying to figure out how to implement&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
    <pubDate>Fri, 14 Jul 2023 14:13:36 GMT</pubDate>
    <dc:creator>lisab80</dc:creator>
    <dc:date>2023-07-14T14:13:36Z</dc:date>
    <item>
      <title>Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093632#M1224193</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Currently I am working on a qlikview app that reads in an agency name and then maps their status as either C or NC&lt;/P&gt;
&lt;P&gt;MapAgency:&lt;BR /&gt;Mapping&lt;BR /&gt;LOAD AgencyName, Status&lt;BR /&gt;FROM ...Agency.xlsx&lt;/P&gt;
&lt;P&gt;and then in my load statement&amp;nbsp;&lt;/P&gt;
&lt;P&gt;APPLYMAP('MapAgency',[Source],null()) as [Agency Type]&lt;/P&gt;
&lt;P&gt;I have now been asked to develop further where based on a date an agency can change status.&lt;/P&gt;
&lt;P&gt;For example in spreadsheet attached Agency1 will always be C as the date field is empty so it keeps its original status, whereas Agency2 starts of as NC and then from 1st Feb 23 the status will be shown as C so any historic data before 01/02/2023 for Agency2 will be shown as NC and any data after this date will be shown as C.&lt;/P&gt;
&lt;P&gt;The logic should cover every AgencyName should be assigned their status from column B initially and then need to do a check is todays date &amp;gt; Date (column c) if yes then Status becomes New Status if no or date is blank then Status does not change&lt;/P&gt;
&lt;P&gt;Any help greatly appreciated&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 16:35:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093632#M1224193</guid>
      <dc:creator>lisab80</dc:creator>
      <dc:date>2023-07-13T16:35:56Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093640#M1224194</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/26827"&gt;@lisab80&lt;/a&gt;&amp;nbsp;!&lt;/P&gt;
&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Try the following condition:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;if(not IsNull(DateField),
	if(DateField&amp;lt;Today(2),
	    if(Status='NC','C','NC'),Status)
,Null()) as NewStatus,&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 13 Jul 2023 17:12:19 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093640#M1224194</guid>
      <dc:creator>joaopaulo_delco</dc:creator>
      <dc:date>2023-07-13T17:12:19Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093844#M1224198</link>
      <description>&lt;P&gt;Hi Joaopaulo_delco&lt;/P&gt;
&lt;P&gt;Not quite sure how that condition will fit into my code because the date field needs to come from the excel sheet attached and the mapping table only reads in AgencyName and Status from the excel sheet attached.&lt;/P&gt;
&lt;P&gt;As the mapping tables can only have 2 columns how do I change my code so I now read in AgencyName, Status, Date and New Status?&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 09:40:29 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093844#M1224198</guid>
      <dc:creator>lisab80</dc:creator>
      <dc:date>2023-07-14T09:40:29Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093900#M1224200</link>
      <description>&lt;P&gt;You can do a "preceding load" after you use the ApplyMap function.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Something like this:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MapAgency:
Mapping
LOAD AgencyName, Status
FROM ...Agency.xlsx

Load
AgencyName,
Status,
Date,
if(not IsNull(Date),
	if(Date&amp;lt;Today(2),
	    if(Status='NC','C','NC'),Status)
,Null()) as NewStatus;
Load 
AgencyName,
APPLYMAP('MapAgency',AgencyName,null()) as Status,
Date
From [lib://path/example.xlsx]...;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 12:09:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093900#M1224200</guid>
      <dc:creator>joaopaulo_delco</dc:creator>
      <dc:date>2023-07-14T12:09:46Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093976#M1224202</link>
      <description>&lt;P&gt;I wanted to clarify something to make it clearer on where i am reading my data from&lt;/P&gt;
&lt;P&gt;My load statement that uses the applymap function is reading from a sql view&lt;/P&gt;
&lt;P&gt;Load&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Fields&lt;/P&gt;
&lt;P&gt;APPLYMAP('MapAgency',[Source],null()) as [Agency Type]&lt;/P&gt;
&lt;P&gt;FROM sql view&lt;/P&gt;
&lt;P&gt;The Source value mentioned in the apply map statement is the Agency Name from my sql view and this then goes to the mapping table and finds the agency name and then returns either NC or C and stores this as [Agency Type]. I have used an excel mapping table as the system that I am reading the data from only stores the AgencyName.&lt;/P&gt;
&lt;P&gt;The mapping table should read from the example.xlsx file&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;MapAgency:&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;Mapping&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;LOAD AgencyName, Status&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;FROM ...example.xlsx&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;Would the suggestion above work as i am still trying to figure out how to implement&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 14:13:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2093976#M1224202</guid>
      <dc:creator>lisab80</dc:creator>
      <dc:date>2023-07-14T14:13:36Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2094035#M1224203</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/26827"&gt;@lisab80&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The kind of source (xlsx, sql, txt) doesn't matter too much.&lt;/P&gt;
&lt;P&gt;Check this out:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;MapAgency:
Mapping
LOAD AgencyName, Status
FROM ...Agency.xlsx

LIB CONNECT TO 'Your string connection';

[TableName]:
Load
AgencyName,
Status,
Date,
if(not IsNull(Date),
	if(Date&amp;lt;Today(2),
	    if(Status='NC','C','NC'),Status)
,Null()) as NewStatus;
Load 
AgencyName,
APPLYMAP('MapAgency',AgencyName,null()) as Status,
Date;
SQL Select 
    AgencyName,
    Date
From YourTable;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 14 Jul 2023 18:26:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2094035#M1224203</guid>
      <dc:creator>joaopaulo_delco</dc:creator>
      <dc:date>2023-07-14T18:26:28Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2094430#M1224215</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;
&lt;P&gt;Thanks for clarifying and it makes sense what you are trying to do my getting the first status then using the date element to overwrite the Status and save as NewStatus.&lt;/P&gt;
&lt;P&gt;I have 1 issue though the Date field is not coming from the SQL view it is coming from the excel file that is used in the MapAgency mapping table.&lt;/P&gt;
&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Mon, 17 Jul 2023 14:20:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2094430#M1224215</guid>
      <dc:creator>lisab80</dc:creator>
      <dc:date>2023-07-17T14:20:03Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2094515#M1224217</link>
      <description>&lt;LI-CODE lang="markup"&gt;MapAgency:
Mapping
LOAD AgencyName, Status
FROM ...Agency.xlsx

MapDate:
Mapping
LOAD AgencyName, Date
FROM ...Agency.xlsx

LIB CONNECT TO 'Your string connection';

[TableName]:
Load
AgencyName,
Status,
Date,
if(not IsNull(Date),
	if(Date&amp;lt;Today(2),
	    if(Status='NC','C','NC'),Status)
,Null()) as NewStatus;
Load 
AgencyName,
ApplyMap('MapAgency', AgencyName,null()) as Status,
ApplyMap('MapDate', AgencyName, null())  as Date;
SQL Select 
    AgencyName
From YourTable;&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 17 Jul 2023 17:11:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2094515#M1224217</guid>
      <dc:creator>joaopaulo_delco</dc:creator>
      <dc:date>2023-07-17T17:11:03Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2095364#M1224245</link>
      <description>&lt;P&gt;I have implemented the above solution&lt;/P&gt;
&lt;DIV&gt;LOAD *,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; if(not IsNull(Date), if(Date&amp;lt;Today(2),if(Status='NC','C','NC'),Status) ,Null()) as NewStatus;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;LOAD&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;other fields,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;APPLYMAP('MapAgency',AgencyName,null()) as Status,&lt;BR /&gt;APPLYMAP('MapDate', AgencyName, null()) as Date;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;from SQL&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;I only applied 1 date for testing to Agency4 with a date of 01/05/2023 (1st may 23).&amp;nbsp; All other AgencyNames had a blank date so they should keep their original status.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Agency4 starts of as C and after 01/05/2023 then it should be shown as NC when I loaded the app this agency is showing as NC irrespective of the date (showing as NC on 01/01/2022 and NC on 02/05/2023) plus all other agency names irrespective of date have the NewStatus value of blank (or - as shown in qlikview)&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Jul 2023 15:36:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2095364#M1224245</guid>
      <dc:creator>lisab80</dc:creator>
      <dc:date>2023-07-19T15:36:11Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2095386#M1224246</link>
      <description>&lt;P&gt;Ignore my previous comment as I have figured out why all the other agencies were showing as blank&lt;/P&gt;
&lt;P&gt;I have updated the code to remove the last NULL() as this was setting all other agency names to blank if their Date value was blank&lt;/P&gt;
&lt;DIV&gt;LOAD *,&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;if(not IsNull(Date), if(Date&amp;lt;ShiftDate,if(Status='NC','C','NC'),Status) ,Status) as NewStatus;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;LOAD&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;other fields,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;APPLYMAP('MapAgency',AgencyName,null()) as Status,&lt;BR /&gt;APPLYMAP('MapDate', AgencyName, null()) as Date;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;from SQL&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;In regards to Agency4 always showing as NC irrespective of the Date this is because using Today will change the status based on the day you load the app not when the shift in the Agency actually happened therefore changing all historic data.&amp;nbsp; I have updated this to now look at ShiftDate and everything is looking good so far.&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;I will run a few more tests and let you know - Thanks&lt;/SPAN&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 19 Jul 2023 16:56:01 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2095386#M1224246</guid>
      <dc:creator>lisab80</dc:creator>
      <dc:date>2023-07-19T16:56:01Z</dc:date>
    </item>
    <item>
      <title>Re: Selecting a value based on a time selection</title>
      <link>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2095822#M1224255</link>
      <description>&lt;P&gt;Thanks for the great solution it worked a treat&lt;/P&gt;</description>
      <pubDate>Thu, 20 Jul 2023 17:04:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Selecting-a-value-based-on-a-time-selection/m-p/2095822#M1224255</guid>
      <dc:creator>lisab80</dc:creator>
      <dc:date>2023-07-20T17:04:49Z</dc:date>
    </item>
  </channel>
</rss>

