<?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 Categorize a field with values in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160776#M34912</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Aldo&lt;/P&gt;&lt;P&gt;I think IntervalMatch is what you are after. Here is an example to clarify:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Step 1:&lt;/B&gt; set up the intervals table. This example sets up 5 named (dual) values for 5 intervals together with the interval minimum and maximum values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;NOTMOVEBANDS:&lt;BR /&gt;LOAD Dual(BandName, DayMin) AS NMoveBand,&lt;BR /&gt; DayMin,&lt;BR /&gt; DayMax&lt;BR /&gt;INLINE&lt;BR /&gt;[&lt;BR /&gt; BandName, DayMin, DayMax&lt;BR /&gt; 'Active', 0, 0&lt;BR /&gt; '&amp;lt;2 Weeks', 1, 14&lt;BR /&gt; '2 - 4 weeks', 14, 28&lt;BR /&gt; '4 - 8 weeks', 28, 56&lt;BR /&gt; '&amp;gt;8 weeks', 56,&lt;BR /&gt;];&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Step 2:&lt;/B&gt; Load the fact table with your field values&lt;/P&gt;&lt;P&gt;&lt;B&gt;Step 3:&lt;/B&gt; Perform the interval match. The example matches the LastMovePeriod field to the intervals defined by DayMin and DayMax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;LEFT JOIN(.... your fact table here ....)&lt;BR /&gt;INTERVALMATCH (LastMovePeriod) LOAD DayMin, DayMax RESIDENT NOTMOVEBANDS;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;That's it. This will result in a synthetic key. If you prefer to remove the synthetic key (not really necessary), then add something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;LEFT JOIN(.... your fact table here ....)&lt;BR /&gt;LOAD DayMin,&lt;BR /&gt; DayMax,&lt;BR /&gt; NMoveBand&lt;BR /&gt;RESIDENT NOTMOVEBANDS;&lt;BR /&gt;&lt;BR /&gt;DROP FIELDS DayMin, DayMax;&lt;BR /&gt;DROP TABLES NOTMOVEBANDS;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;This last script adds the NMoveBand field (the matched dual value) to the fact table and then deletes the DayMin/DayMax values and the NOTMOVEBANDS intervals table.&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 10 Jan 2011 06:41:30 GMT</pubDate>
    <dc:creator>jonathandienst</dc:creator>
    <dc:date>2011-01-10T06:41:30Z</dc:date>
    <item>
      <title>Categorize a field with values</title>
      <link>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160772#M34908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I have a field with values between o and 50,000&lt;/P&gt;&lt;P&gt;I need to category it, like:&lt;/P&gt;&lt;P&gt;Less than 100&lt;/P&gt;&lt;P&gt;Less than 250&lt;/P&gt;&lt;P&gt;Less than 500&lt;/P&gt;&lt;P&gt;and so on...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know two ways to do that:&lt;/P&gt;&lt;P&gt;1.- concatenating several if statements.&lt;/P&gt;&lt;P&gt;2. Creating an auxiliary table with two fields, one with all posxible values, the second one with the category for each value (using in line or external file).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The issue is that, in te first case I have to deal with too much if statements.&lt;/P&gt;&lt;P&gt;In the second case, I have to list ALL possible values (up to 50,000 or even more)..&lt;/P&gt;&lt;P&gt;Is there any other option?&lt;/P&gt;&lt;P&gt;Thanks in advance,&lt;/P&gt;&lt;P&gt;Aldo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jan 2011 13:12:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160772#M34908</guid>
      <dc:creator />
      <dc:date>2011-01-09T13:12:53Z</dc:date>
    </item>
    <item>
      <title>Categorize a field with values</title>
      <link>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160773#M34909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Where are you getting the data from? if this is a database server there are always options to put it there. For example MSSQL has the case statement where you could do something as the following:&lt;/P&gt;&lt;P&gt;SELECT Value&lt;/P&gt;&lt;P&gt;, CASE&lt;/P&gt;&lt;P&gt;WHEN Value BETWEEN 0 AND 99 THEN 'Less then 100'&lt;/P&gt;&lt;P&gt;WHEN Value BETWEEN 100 AND 199 THEN 'Less then 200'&lt;/P&gt;&lt;P&gt;ELSE '200 or more'&lt;/P&gt;&lt;P&gt;END AS ValueCategory&lt;/P&gt;&lt;P&gt;FROM Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It is basically the same as an if-statement in your script. Is it not that the case statement is quite a bit more concise.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jan 2011 13:56:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160773#M34909</guid>
      <dc:creator />
      <dc:date>2011-01-09T13:56:53Z</dc:date>
    </item>
    <item>
      <title>Categorize a field with values</title>
      <link>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160774#M34910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I believe CASE WHEN doesn't work with data.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jan 2011 14:04:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160774#M34910</guid>
      <dc:creator />
      <dc:date>2011-01-09T14:04:55Z</dc:date>
    </item>
    <item>
      <title>Categorize a field with values</title>
      <link>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160775#M34911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Now you lost me a bit, but it definitely works in the SQL part of the load statement. See the below example:&lt;/P&gt;&lt;P&gt;Values:&lt;/P&gt;&lt;P&gt;LOAD Value&lt;/P&gt;&lt;P&gt;, CategoryValue&lt;/P&gt;&lt;P&gt;SQL SELECT Value&lt;/P&gt;&lt;P&gt;CASE WHEN .... THEN.... ELSE.... END AS CategoryValue&lt;/P&gt;&lt;P&gt;FROM Table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Ofcourse if your data is not coming from a database server this won't work. Another option could be to create a data-island with 3 columns (from, to, description) and then by using a set-analyse get the right description. Though problems like you describe i would always fix as close to the source as possible.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 09 Jan 2011 21:12:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160775#M34911</guid>
      <dc:creator />
      <dc:date>2011-01-09T21:12:30Z</dc:date>
    </item>
    <item>
      <title>Categorize a field with values</title>
      <link>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160776#M34912</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Aldo&lt;/P&gt;&lt;P&gt;I think IntervalMatch is what you are after. Here is an example to clarify:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Step 1:&lt;/B&gt; set up the intervals table. This example sets up 5 named (dual) values for 5 intervals together with the interval minimum and maximum values.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;NOTMOVEBANDS:&lt;BR /&gt;LOAD Dual(BandName, DayMin) AS NMoveBand,&lt;BR /&gt; DayMin,&lt;BR /&gt; DayMax&lt;BR /&gt;INLINE&lt;BR /&gt;[&lt;BR /&gt; BandName, DayMin, DayMax&lt;BR /&gt; 'Active', 0, 0&lt;BR /&gt; '&amp;lt;2 Weeks', 1, 14&lt;BR /&gt; '2 - 4 weeks', 14, 28&lt;BR /&gt; '4 - 8 weeks', 28, 56&lt;BR /&gt; '&amp;gt;8 weeks', 56,&lt;BR /&gt;];&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;B&gt;Step 2:&lt;/B&gt; Load the fact table with your field values&lt;/P&gt;&lt;P&gt;&lt;B&gt;Step 3:&lt;/B&gt; Perform the interval match. The example matches the LastMovePeriod field to the intervals defined by DayMin and DayMax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;LEFT JOIN(.... your fact table here ....)&lt;BR /&gt;INTERVALMATCH (LastMovePeriod) LOAD DayMin, DayMax RESIDENT NOTMOVEBANDS;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;That's it. This will result in a synthetic key. If you prefer to remove the synthetic key (not really necessary), then add something like:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;BLOCKQUOTE style="overflow-x: scroll;"&gt;&lt;PRE style="margin: 0px;"&gt;LEFT JOIN(.... your fact table here ....)&lt;BR /&gt;LOAD DayMin,&lt;BR /&gt; DayMax,&lt;BR /&gt; NMoveBand&lt;BR /&gt;RESIDENT NOTMOVEBANDS;&lt;BR /&gt;&lt;BR /&gt;DROP FIELDS DayMin, DayMax;&lt;BR /&gt;DROP TABLES NOTMOVEBANDS;&lt;/PRE&gt;&lt;/BLOCKQUOTE&gt;&lt;BR /&gt;&lt;BR /&gt; &lt;P&gt;&lt;/P&gt;&lt;P&gt;This last script adds the NMoveBand field (the matched dual value) to the fact table and then deletes the DayMin/DayMax values and the NOTMOVEBANDS intervals table.&lt;/P&gt;&lt;P&gt;Hope that helps.&lt;/P&gt;&lt;P&gt;Jonathan&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jan 2011 06:41:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160776#M34912</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2011-01-10T06:41:30Z</dc:date>
    </item>
    <item>
      <title>Categorize a field with values</title>
      <link>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160777#M34913</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Great, exacly what I was looking for.&lt;/P&gt;&lt;P&gt;Thanks guys.&lt;/P&gt;&lt;P&gt;Aldo.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 10 Jan 2011 12:55:53 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Categorize-a-field-with-values/m-p/160777#M34913</guid>
      <dc:creator />
      <dc:date>2011-01-10T12:55:53Z</dc:date>
    </item>
  </channel>
</rss>

