<?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: IF statement in expression - applying Min(IF()) to field in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915346#M469104</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Jonathan, I have attached a sample file in the original post. I would appreciate your thoughts.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Jul 2015 00:25:54 GMT</pubDate>
    <dc:creator />
    <dc:date>2015-07-28T00:25:54Z</dc:date>
    <item>
      <title>IF statement in expression - applying Min(IF()) to field</title>
      <link>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915342#M469100</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 have a list of tariffs that have a 'begin date' and 'end date' and thus a tariff duration (the difference between the two dates).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The required tariff is the one that falls between the begin and end dates, with the lowest duration.&lt;/P&gt;&lt;P&gt;i.e. there may be tariffs set from 1 Jan to 31 Jan, but if there is another tariff set for 4 Jan to 5 Jan, then this tariff will override the whole month duration.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So, I need an expression that can return the tariff for each of the dates in calendar date dimension, where the tariff duration is the minimum for that date.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This expression will give me the minimum duration which I put into the first expression - Column(1):&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Min( &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; If ( &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyDate &amp;gt;= BEGIN_DATE and &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyDate &amp;lt;= END_DATE &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; , TARIFF_DURATION))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;This next expression needs to use the minimum tariff duration determined from the above expression to return the average tariff with that duration:&lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;Avg( &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If ( &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyDate &amp;gt;= BEGIN_DATE and &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; KeyDate &amp;lt;= END_DATE and &lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TARIFF_DURATION = Column(1) &lt;/SPAN&gt;&lt;/P&gt;&lt;P style="padding-left: 30px;"&gt;&lt;SPAN style="font-family: 'courier new', courier;"&gt;, TARIFF))&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;But I can't get this to work.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ideally, I would like to do the whole expression in one step.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;EDIT:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Refer attached sample file that shows a simplified version of what I am trying to achieve.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The "Average Tariff" averages all tariffs that there is a date range for - not what I want&lt;/LI&gt;&lt;LI&gt;The Min Tariff Duration is what I need to filter by &lt;/LI&gt;&lt;LI&gt;The third expression is the one that I need to work. I have tried to refer to the column that has the minimum tariff duration.&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: Andrew Noble&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jul 2015 02:23:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915342#M469100</guid>
      <dc:creator />
      <dc:date>2015-07-27T02:23:50Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement in expression - applying Min(IF()) to field</title>
      <link>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915343#M469101</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Would you be able to provide some sample data to work with???? It would be easier to approach the problem with actually testing the stuff out.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Best,&lt;/P&gt;&lt;P&gt;Sunny&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jul 2015 10:28:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915343#M469101</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2015-07-27T10:28:00Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement in expression - applying Min(IF()) to field</title>
      <link>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915344#M469102</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;You could land up with very poor performance doing this sort of processing in the front end. I would explore adding some processing to the load script. I assume that the 'correct' tariff is not subject to user selections, and if that is the case, you could calculate the tariff during the load process.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You would probably need a master calendar with all the dates in the date range of interest and you could apply the product names and tariffs to the calendar using an interval match, creating a date/product/tariff table with the tariff 'from' and 'to' dates. You could then flag the tariffs that have the lowest duration and you could use a set expression in the front end to select the 'correct' tariffs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I can only give these general guidelines unless you can post some sample data and your qvw. &lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 27 Jul 2015 11:17:50 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915344#M469102</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2015-07-27T11:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement in expression - applying Min(IF()) to field</title>
      <link>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915345#M469103</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sunny, I have attached a sample file in the original post. I would appreciate your thoughts.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2015 00:25:43 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915345#M469103</guid>
      <dc:creator />
      <dc:date>2015-07-28T00:25:43Z</dc:date>
    </item>
    <item>
      <title>Re: IF statement in expression - applying Min(IF()) to field</title>
      <link>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915346#M469104</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN style="font-size: 13.3333330154419px;"&gt;Jonathan, I have attached a sample file in the original post. I would appreciate your thoughts.&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Jul 2015 00:25:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/IF-statement-in-expression-applying-Min-IF-to-field/m-p/915346#M469104</guid>
      <dc:creator />
      <dc:date>2015-07-28T00:25:54Z</dc:date>
    </item>
  </channel>
</rss>

