<?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: &amp;quot;If then else&amp;quot; equivalent inside load? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832907#M293044</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't conditionally create the field, you can only conditionally create the field value. My usual approach is to go through and create all the fields (even the nulls) and then break the table into normalized pieces to create the one to many relationships. See this example:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Qlikview Cookbook: Load Input File Containing Multiple Record Types &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com/recipes/download-info/load-input-file-containing-multiple-record-types/" rel="nofollow"&gt;http://qlikviewcookbook.com/recipes/download-info/load-input-file-containing-multiple-record-types/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another approach I use is to take one pas through the data to assign ids (for inter-record association) and "tag" the records with a type. Then process the resident table with multiple LOAD where type="".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 14 Apr 2015 17:52:42 GMT</pubDate>
    <dc:creator>rwunderlich</dc:creator>
    <dc:date>2015-04-14T17:52:42Z</dc:date>
    <item>
      <title>"If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832904#M293041</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 loading log files and trying to parse them into something reasonable for qlikview.&lt;/P&gt;&lt;P&gt;Am I going at it in a silly way, should I just quit trying and do conversion with something else before loading into qv or can you think of something to make the script reasonable?&lt;/P&gt;&lt;P&gt;I don't want to go through writing all the conditions (might be more than 50) just to realize that it would take ages to run it for a millions of log lines. Is there a way to include the field name inside If statement so I could first try the most common ones like this: "If something then this As id Else if....". Or are my performance concerns unnecessary?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;log: LOAD @1 As line &lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;FROM log.txt (txt, codepage is 1252, no labels, delimiter is \x7, msq); //load the log&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp1: &lt;/P&gt;&lt;P&gt;LOAD line,&lt;/P&gt;&lt;P&gt;If(left(line,8)='login ID',mid(line,10,10) As id,&lt;/P&gt;&lt;P&gt;if(left(line,8)='Username',mid(line,10,10) As user,&lt;/P&gt;&lt;P&gt;if(left(line,14)='End of session', 'eos') As eos,&lt;/P&gt;&lt;P&gt;....lots of similar comparisons with things that I want to pull info from to different fields....&lt;/P&gt;&lt;P&gt;RESIDENT temp1;&lt;/P&gt;&lt;P&gt;drop table log;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;temp2:&lt;/P&gt;&lt;P&gt;LOAD &lt;/P&gt;&lt;P&gt;If(isnull(id), peek(id), id) As id,&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //peek to copy the id from the previous line&lt;/P&gt;&lt;P&gt;If(isnull(user), peek(user), user) As id, &lt;SPAN style="font-size: 13.3333330154419px;"&gt;//peek to copy the id from the previous line&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;......&lt;/P&gt;&lt;P&gt;RESIDENT temp2;&lt;/P&gt;&lt;P&gt;drop table temp1;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 17:26:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832904#M293041</guid>
      <dc:creator />
      <dc:date>2015-04-14T17:26:40Z</dc:date>
    </item>
    <item>
      <title>Re: "If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832905#M293042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The syntax for the IF statement does allow for nesting&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF(MyExpressionIsTrue, THEN DO THIS, ELSE DO THIS)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF(MyExpressionIsTrue, THEN DO THIS,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(MyExpressionsIsSomethingElseInstead, THEN DO THIS,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(MyExpressionsIsAThirdThing, THEN DO THIS, ELSE DO THIS IF IT Didn't Match anything)))&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 17:31:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832905#M293042</guid>
      <dc:creator />
      <dc:date>2015-04-14T17:31:13Z</dc:date>
    </item>
    <item>
      <title>Re: "If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832906#M293043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Inside LOAD I can only get a value to put in a field:&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 10pt; line-height: 1.5em;"&gt;If(1=1, 'blabla') As this,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;But I would like the field name to be inside the condition too so I I could do:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If(x=1, 'blabla' As this,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(x=2, '2blabla' As that,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(x=3.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;edit: field name changing this,that... etc.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 17:40:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832906#M293043</guid>
      <dc:creator />
      <dc:date>2015-04-14T17:40:12Z</dc:date>
    </item>
    <item>
      <title>Re: "If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832907#M293044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You can't conditionally create the field, you can only conditionally create the field value. My usual approach is to go through and create all the fields (even the nulls) and then break the table into normalized pieces to create the one to many relationships. See this example:&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Qlikview Cookbook: Load Input File Containing Multiple Record Types &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://qlikviewcookbook.com/recipes/download-info/load-input-file-containing-multiple-record-types/" rel="nofollow"&gt;http://qlikviewcookbook.com/recipes/download-info/load-input-file-containing-multiple-record-types/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Another approach I use is to take one pas through the data to assign ids (for inter-record association) and "tag" the records with a type. Then process the resident table with multiple LOAD where type="".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 17:52:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832907#M293044</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2015-04-14T17:52:42Z</dc:date>
    </item>
    <item>
      <title>Re: "If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832908#M293045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you could do it but not on the way you want, QV if's are similar to SQL cases where each case has an specific name,&lt;/P&gt;&lt;P&gt;though you can try by doing something like this&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;If(x=1, 'blabla' As this&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&lt;SPAN style="line-height: 1.5em;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if(&lt;SPAN style="color: #3d3d3d; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; font-size: 13px;"&gt;x&amp;lt;&amp;gt;1 and&amp;nbsp; &lt;/SPAN&gt;&lt;/SPAN&gt;&lt;SPAN style="line-height: 1.5em;"&gt;x=2, '2blabla' As that,&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="font-size: 13px; font-family: 'Helvetica Neue', Helvetica, Arial, 'Lucida Grande', sans-serif; color: #3d3d3d;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; etc ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 17:55:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832908#M293045</guid>
      <dc:creator>ramoncova06</dc:creator>
      <dc:date>2015-04-14T17:55:22Z</dc:date>
    </item>
    <item>
      <title>Re: "If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832909#M293046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There is something that can help:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;IF A=B THEN&lt;/P&gt;&lt;P&gt;some script, e.g.&lt;BR /&gt;LOAD&lt;BR /&gt; ...&lt;BR /&gt; blabla as this,&lt;BR /&gt; ...&lt;BR /&gt;FROM&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;ELSE&lt;/P&gt;&lt;P&gt;some other script, e.g.&lt;BR /&gt;LOAD&lt;BR /&gt; ...&lt;BR /&gt; blabla as that,&lt;BR /&gt; ...&lt;BR /&gt;FROM&lt;BR /&gt;...&lt;/P&gt;&lt;P&gt;ENDIF&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 17:57:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832909#M293046</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-04-14T17:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: "If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832910#M293047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;BLOCKQUOTE&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;Another approach I use is to take one pas through the data to assign ids (for inter-record association) and "tag" the records with a type. Then process the resident table with multiple LOAD where type="".&lt;/P&gt;
&lt;P&gt;&lt;/P&gt;
&lt;P&gt;-Rob&lt;/P&gt;
&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;I thought about this too but I came to the conclusion that it doesn't change that much. I'd still have to go through all the individual if statements to "tag" the line. &lt;/P&gt;&lt;P&gt;Guess I'll just try and see if there will be any performance issues.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 18:23:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832910#M293047</guid>
      <dc:creator />
      <dc:date>2015-04-14T18:23:47Z</dc:date>
    </item>
    <item>
      <title>Re: "If then else" equivalent inside load?</title>
      <link>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832911#M293048</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;The tagging approach can simplify things a bit. You can do the tagging with a map instead of if(). And then each load statement deals only with the fields it knows will be on that record type, eliminating additional if(). &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 14 Apr 2015 22:10:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/quot-If-then-else-quot-equivalent-inside-load/m-p/832911#M293048</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2015-04-14T22:10:40Z</dc:date>
    </item>
  </channel>
</rss>

