<?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 New field conditional on two variables in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/New-field-conditional-on-two-variables/m-p/890279#M654683</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working a creating a new field that is conditional on two variables. There are the following fields:&lt;/P&gt;&lt;P&gt;1) Invoice (INVOICE)&lt;/P&gt;&lt;P&gt;2) Debit/Credit Indicator (DEB_CRED) - has two values, H or S&lt;/P&gt;&lt;P&gt;3) Line Item Number (LINE_NUM)&lt;/P&gt;&lt;P&gt;4) Document Type (DOC_TYPE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need is a new Debit Credit Indicator where I change some of the values. In each invoice there are a number of lines with various DEB_CRED depending on what is relevant. For this new field that I need, I generally need the DEB_CRED of the first LINE_NUM to be transferred to all other lines on that INVOICE. So if line 5 says H but line 1 says S, then I want line 5 in the new field to follow line 1 and say S. However, to complicate matters I have one particular DOC_TYPE where I don't want my new field to change any values, but remain as in the original field. Let's call this DOC_TYPE&amp;nbsp; "KA".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am guessing that I need a load statement with some sort of IF expression, but am open to other suggestions. Something along the lines of: &lt;/P&gt;&lt;P&gt;IF DOC_TYPE = KA &lt;/P&gt;&lt;P&gt;THEN NEW_FIELD_NAME_DEB_CRED_2,&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (if not)&lt;/P&gt;&lt;P&gt;DEB_CRED should display same value as LINE_NUM 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or maybe a Load where&lt;/P&gt;&lt;P&gt;DEB_CRED as DEB_CRED_2 &lt;EM&gt;where&lt;/EM&gt; DOC_TYPE = KA &lt;EM&gt;and&lt;/EM&gt; &lt;EM&gt;IF DOC_TYPE&lt;/EM&gt; &amp;lt;&amp;gt; KA, &lt;EM&gt;then&lt;/EM&gt; fill in same value as LINE_NUM 1 for all remaining values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help me with scripting this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 16 Jul 2015 13:37:57 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-07-16T13:37:57Z</dc:date>
    <item>
      <title>New field conditional on two variables</title>
      <link>https://community.qlik.com/t5/QlikView/New-field-conditional-on-two-variables/m-p/890279#M654683</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am working a creating a new field that is conditional on two variables. There are the following fields:&lt;/P&gt;&lt;P&gt;1) Invoice (INVOICE)&lt;/P&gt;&lt;P&gt;2) Debit/Credit Indicator (DEB_CRED) - has two values, H or S&lt;/P&gt;&lt;P&gt;3) Line Item Number (LINE_NUM)&lt;/P&gt;&lt;P&gt;4) Document Type (DOC_TYPE)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need is a new Debit Credit Indicator where I change some of the values. In each invoice there are a number of lines with various DEB_CRED depending on what is relevant. For this new field that I need, I generally need the DEB_CRED of the first LINE_NUM to be transferred to all other lines on that INVOICE. So if line 5 says H but line 1 says S, then I want line 5 in the new field to follow line 1 and say S. However, to complicate matters I have one particular DOC_TYPE where I don't want my new field to change any values, but remain as in the original field. Let's call this DOC_TYPE&amp;nbsp; "KA".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am guessing that I need a load statement with some sort of IF expression, but am open to other suggestions. Something along the lines of: &lt;/P&gt;&lt;P&gt;IF DOC_TYPE = KA &lt;/P&gt;&lt;P&gt;THEN NEW_FIELD_NAME_DEB_CRED_2,&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (if not)&lt;/P&gt;&lt;P&gt;DEB_CRED should display same value as LINE_NUM 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Or maybe a Load where&lt;/P&gt;&lt;P&gt;DEB_CRED as DEB_CRED_2 &lt;EM&gt;where&lt;/EM&gt; DOC_TYPE = KA &lt;EM&gt;and&lt;/EM&gt; &lt;EM&gt;IF DOC_TYPE&lt;/EM&gt; &amp;lt;&amp;gt; KA, &lt;EM&gt;then&lt;/EM&gt; fill in same value as LINE_NUM 1 for all remaining values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Can someone help me with scripting this?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 13:37:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-field-conditional-on-two-variables/m-p/890279#M654683</guid>
      <dc:creator />
      <dc:date>2015-07-16T13:37:57Z</dc:date>
    </item>
    <item>
      <title>Re: New field conditional on two variables</title>
      <link>https://community.qlik.com/t5/QlikView/New-field-conditional-on-two-variables/m-p/890280#M654684</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I'm going to assume your data source is ordered by invoice and line number already. If it isn't then you first need to load to load the unsorted data and then use a resident load to order the data. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use the Previous and Peek functions. Something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOAD&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; INVOICE,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DEB_CRED,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; LINE_NUM,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DOC_TYPE,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; IF(INVOICE = Previous(INVOICE) AND DOC_TYPE &amp;lt;&amp;gt; 'KA', peek('&lt;SPAN style="font-size: 13.3333330154419px;"&gt;DEB_CRED2&lt;/SPAN&gt;'), DEB_CRED) as DEB_CRED2&lt;/P&gt;&lt;P&gt;FROM ...&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 16 Jul 2015 16:14:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-field-conditional-on-two-variables/m-p/890280#M654684</guid>
      <dc:creator>Gysbert_Wassenaar</dc:creator>
      <dc:date>2015-07-16T16:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: New field conditional on two variables</title>
      <link>https://community.qlik.com/t5/QlikView/New-field-conditional-on-two-variables/m-p/890281#M654685</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/check.png" /&gt; It worked perfectly! Thank you so much. &lt;IMG src="https://community.qlik.com/legacyfs/online/emoticons/happy.png" /&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 17 Jul 2015 05:58:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/New-field-conditional-on-two-variables/m-p/890281#M654685</guid>
      <dc:creator />
      <dc:date>2015-07-17T05:58:53Z</dc:date>
    </item>
  </channel>
</rss>

