<?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 Variables/Calculation in load script in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Variables-Calculation-in-load-script/m-p/1141268#M914941</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 struggling to find out how best to go about the following problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a list of projects which I want to calculate a project status on (red, amber, green) dependent on how far the project has elapsed, and how much of the project has completed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I load the following:&lt;/P&gt;&lt;PRE __default_attr="xml" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14641727121418068 jive_text_macro" jivemacro_uid="_14641727121418068" modifiedtitle="true"&gt;
&lt;P style="font-size: 13.3333px;"&gt;SharedData:&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;LOAD distinct number as [Project Number], &lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Date#(mid([work_start],1,17),'DD-MMM-YYYY hh:mm'), 'DD-MM-YYYY') as [Project Actual Start Date],&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Date#(mid([work_end],1,17),'DD-MMM-YYYY hh:mm'), 'DD-MM-YYYY') as [Project Actual End Date],&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; percent_complete as [Percent Complete] &lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;FROM&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;[..\&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000;"&gt;..\30_GLOBAL_SOURCES\QLIKVIEW - PROJECT TASK TTS.csv]&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then, in pseudo code, would like to do the following in order to find out the status of the project based on the table below - I think I would do this in the Load script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TotalProjectDuration = [Project Actual End Date] - [Project Actual Start Date]&lt;/P&gt;&lt;P&gt;ElapsedTime = Today() - &lt;SPAN style="font-size: 13.3333px;"&gt;[Project Actual Start Date]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PercentageElapsed =&amp;nbsp; ElapsedTime/TotalProjectDuration*100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Status = IF ( &lt;SPAN style="font-size: 13.3333px;"&gt;PercentageElapsed = 100% AND Percent complete &amp;lt;&amp;gt; 100%, RED...&amp;nbsp; based on below&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;IMG alt="image.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/125742_image.png" style="height: 191px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;I would then like to join 'status' so I am left with&amp;nbsp; one table with the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Project Number]&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; [Project Actual End Date] &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; [Project Actual Start Date]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;[Percent Complete]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;[Status]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Would it be best to achieve this with a For loop after the Load statement to go through each row in resident SharedData? If so, could someone provide me with some rough syntax to help me achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lizi&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
    <dc:creator />
    <dc:date>2020-11-25T16:16:04Z</dc:date>
    <item>
      <title>Variables/Calculation in load script</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-Calculation-in-load-script/m-p/1141268#M914941</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 struggling to find out how best to go about the following problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have a list of projects which I want to calculate a project status on (red, amber, green) dependent on how far the project has elapsed, and how much of the project has completed.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I load the following:&lt;/P&gt;&lt;PRE __default_attr="xml" __jive_macro_name="code" class="jive_macro_code _jivemacro_uid_14641727121418068 jive_text_macro" jivemacro_uid="_14641727121418068" modifiedtitle="true"&gt;
&lt;P style="font-size: 13.3333px;"&gt;SharedData:&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;LOAD distinct number as [Project Number], &lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp; &lt;SPAN style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Date#(mid([work_start],1,17),'DD-MMM-YYYY hh:mm'), 'DD-MM-YYYY') as [Project Actual Start Date],&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Date#(mid([work_end],1,17),'DD-MMM-YYYY hh:mm'), 'DD-MM-YYYY') as [Project Actual End Date],&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; percent_complete as [Percent Complete] &lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;FROM&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;[..\&lt;/P&gt;
&lt;P style="font-size: 13.3333px;"&gt;&lt;SPAN style="color: #000000;"&gt;..\30_GLOBAL_SOURCES\QLIKVIEW - PROJECT TASK TTS.csv]&lt;/SPAN&gt;&lt;/P&gt;
&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I then, in pseudo code, would like to do the following in order to find out the status of the project based on the table below - I think I would do this in the Load script:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;TotalProjectDuration = [Project Actual End Date] - [Project Actual Start Date]&lt;/P&gt;&lt;P&gt;ElapsedTime = Today() - &lt;SPAN style="font-size: 13.3333px;"&gt;[Project Actual Start Date]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;PercentageElapsed =&amp;nbsp; ElapsedTime/TotalProjectDuration*100&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Status = IF ( &lt;SPAN style="font-size: 13.3333px;"&gt;PercentageElapsed = 100% AND Percent complete &amp;lt;&amp;gt; 100%, RED...&amp;nbsp; based on below&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;IMG alt="image.png" class="jive-image image-1" src="https://community.qlik.com/legacyfs/online/125742_image.png" style="height: 191px; width: 620px;" /&gt;&lt;/P&gt;&lt;P&gt;I would then like to join 'status' so I am left with&amp;nbsp; one table with the following:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Project Number]&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; [Project Actual End Date] &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt; [Project Actual Start Date]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;[Percent Complete]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;[Status]&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Would it be best to achieve this with a For loop after the Load statement to go through each row in resident SharedData? If so, could someone provide me with some rough syntax to help me achieve this?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Lizi&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/Variables-Calculation-in-load-script/m-p/1141268#M914941</guid>
      <dc:creator />
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Variables/Calculation in load script</title>
      <link>https://community.qlik.com/t5/QlikView/Variables-Calculation-in-load-script/m-p/1141269#M914942</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Lizi&lt;/P&gt;&lt;P&gt;For your calculated fields you can use preceding load like this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;SharedData: &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;LOAD *,&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; ElapsedTime/TotalProjectDuration*100&amp;nbsp; as PercentageElapsed&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;LOAD *,&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; DATE([Project Actual End Date] - [Project Actual Start Date]) as TotalProjectDuration ,&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp; DATE(Today(1) - [Project Actual Start Date]) as ElapsedTime &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;LOAD distinct number as [Project Number], &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Date#(mid([work_start],1,17),'DD-MMM-YYYY hh:mm'), 'DD-MM-YYYY') as [Project Actual Start Date], &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date(Date#(mid([work_end],1,17),'DD-MMM-YYYY hh:mm'), 'DD-MM-YYYY') as [Project Actual End Date], &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; percent_complete as [Percent Complete] &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;FROM &lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;[..\..\30_GLOBAL_SOURCES\QLIKVIEW - PROJECT TASK TTS.csv];&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;The colors can be defined at chart level with the background color property or also in the top level preceding load.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Please let me know if this helps.&lt;/P&gt;&lt;P style="font-size: 13.3333330154419px;"&gt;Kind regards,&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 25 May 2016 13:01:15 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Variables-Calculation-in-load-script/m-p/1141269#M914942</guid>
      <dc:creator>santiago_respane</dc:creator>
      <dc:date>2016-05-25T13:01:15Z</dc:date>
    </item>
  </channel>
</rss>

