<?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: Perform an average in script if in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497119#M1226299</link>
    <description>&lt;P&gt;Average of what? What is n? Your sample doesn't really explain what the incoming data and expected outcome are. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Dec 2024 14:44:45 GMT</pubDate>
    <dc:creator>Or</dc:creator>
    <dc:date>2024-12-10T14:44:45Z</dc:date>
    <item>
      <title>Perform an average in script if</title>
      <link>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497113#M1226298</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I want a new field that returns the average (n) if 'Apple' appears in the field value, otherwise return 'n'. I just can't figure it out.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="AvgInScript.PNG" style="width: 217px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/175498iD027E7DAF0BC3E5E/image-size/large?v=v2&amp;amp;px=999" role="button" title="AvgInScript.PNG" alt="AvgInScript.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 14:35:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497113#M1226298</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-10T14:35:26Z</dc:date>
    </item>
    <item>
      <title>Re: Perform an average in script if</title>
      <link>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497119#M1226299</link>
      <description>&lt;P&gt;Average of what? What is n? Your sample doesn't really explain what the incoming data and expected outcome are. &lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 14:44:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497119#M1226299</guid>
      <dc:creator>Or</dc:creator>
      <dc:date>2024-12-10T14:44:45Z</dc:date>
    </item>
    <item>
      <title>Re: Perform an average in script if</title>
      <link>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497173#M1226300</link>
      <description>&lt;P&gt;If I understand your desired output correctly, then you could calculate the average(n) first and store it in a variable. Then you can load your entire table and decide with the wildmatch() function, if the Field includes the word '*Apple*', and save either the value of n or the avg(n) from the variable.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Data:
LOAD * INLINE [
Field, n
Green Apple 1, 6
Red Apple 2, 8
Pear 3, 4
Orange 2, 7
Pear 1, 5
];

Temp:
LOAD AVG(n) AS AvgN
RESIDENT Data;

Let vAverage = Peek('AvgN');


Avg:
LOAD *,
IF(WildMatch(Field, '*Apple*'), $(vAverage) , n) AS New_Field
RESIDENT Data;

Drop Table Data, Temp; &lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Output Tabel:&lt;BR /&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="NoahF_0-1733859510060.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/175517iEEFC22FC103AB4F6/image-size/medium?v=v2&amp;amp;px=400" role="button" title="NoahF_0-1733859510060.png" alt="NoahF_0-1733859510060.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Dec 2024 19:41:26 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497173#M1226300</guid>
      <dc:creator>NoahF</dc:creator>
      <dc:date>2024-12-10T19:41:26Z</dc:date>
    </item>
    <item>
      <title>Re: Perform an average in script if</title>
      <link>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497329#M1226302</link>
      <description>&lt;P&gt;Thank you so much!&lt;/P&gt;</description>
      <pubDate>Wed, 11 Dec 2024 10:35:57 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Perform-an-average-in-script-if/m-p/2497329#M1226302</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-11T10:35:57Z</dc:date>
    </item>
  </channel>
</rss>

