<?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: Age range with If in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542749#M1137497</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are more efficient ways to do this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/thread/4967"&gt;creating an age group from a date field&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 10 Oct 2013 16:47:02 GMT</pubDate>
    <dc:creator>swuehl</dc:creator>
    <dc:date>2013-10-10T16:47:02Z</dc:date>
    <item>
      <title>Age range with If</title>
      <link>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542748#M1137496</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;A bit of a novice with the script here and in need of a bit of support...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the following Load which isn't working due to the added "if".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would like to take the customers DOB and apply those into the bands shown below so as to compare age ranges to products purchased; Any help would be appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CustomerProfile:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;CustDateOfBirth,&lt;BR /&gt;Date (Floor(CustDateOfBirth)), 'DD/MM/YYYY' as DobDate,&lt;BR /&gt;Year(Today(1))-Year(Date(CustDateOfBirth)) AS CustAge,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustFirstTransaction,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustID;&lt;BR /&gt;Left Join&lt;BR /&gt;Load *,&lt;BR /&gt; If (CustAge &amp;lt;=20, AgeUnder20, &lt;BR /&gt; If (CustAge &amp;gt;20&amp;lt;=30, Age20_30, &lt;BR /&gt; If (CustAge &amp;gt;30&amp;lt;=40, Age30_40, &lt;BR /&gt; If(CustAge &amp;gt;40&amp;lt;=50, Age40_50, &lt;BR /&gt; If (CustAge &amp;gt;50&amp;lt;=60, Age50_60, &lt;BR /&gt; If (CustAge &amp;gt;60&amp;lt;=70, Age60_70, 'Over70')))))) as AgeBand;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL SELECT CustDateOfBirth,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustFirstTransaction,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; CustID&lt;SPAN&gt;&lt;BR /&gt;FROM **************; &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;Thanks &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;&lt;SPAN style="font-size: 8pt;"&gt;P&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2013 16:39:38 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542748#M1137496</guid>
      <dc:creator>pauledrich</dc:creator>
      <dc:date>2013-10-10T16:39:38Z</dc:date>
    </item>
    <item>
      <title>Re: Age range with If</title>
      <link>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542749#M1137497</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;There are more efficient ways to do this:&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/thread/4967"&gt;creating an age group from a date field&lt;/A&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2013 16:47:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542749#M1137497</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-10-10T16:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Age range with If</title>
      <link>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542750#M1137498</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the reply.... I have amended from the helpfile to what is below - during debug QV isn't recognising the "CustAge" field I created from the "CustDateOfBirth" Field, I have tried "[CustAge]", 'CustAge' - clearly im making a basic error somewhere?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CustomerProfile:&lt;/P&gt;&lt;P&gt;Load&lt;/P&gt;&lt;P&gt;CustDateOfBirth,&lt;/P&gt;&lt;P&gt;Date (Floor(CustDateOfBirth)), 'DD/MM/YYYY' as DobDate,&lt;/P&gt;&lt;P&gt;Year(Today(1))-Year(Date(CustDateOfBirth)) AS CustAge,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustFirstTransaction,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustID;&lt;/P&gt;&lt;P&gt;Left Join&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;If (CustAge &amp;lt;=20, 'AgeUnder20',&lt;/P&gt;&lt;P&gt;If (CustAge&amp;gt;20 and CustAge &amp;lt;=30, 'Age20_30',&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;30 and CustAge &amp;lt;=40, 'Age30_40',&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;40 and CustAge &amp;lt;=50, 'Age40_50',&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;50 and CustAge &amp;lt;=60, 'Age50_60',&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;60 and CustAge &amp;lt;=70, 'Age60_70', 'Over70')))))) as AgeBand;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;SQL SELECT CustDateOfBirth,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustFirstTransaction,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustID&lt;/P&gt;&lt;P&gt;FROM *******;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2013 17:57:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542750#M1137498</guid>
      <dc:creator>pauledrich</dc:creator>
      <dc:date>2013-10-10T17:57:12Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Re: Age range with If</title>
      <link>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542751#M1137499</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Ok, if you want to go with the if() statements, you need to correct the order of your preceding loads (you need to read the load statements from the bottom up, like a pipe), and don't think you should use the left join here:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;CustomerProfile:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Load *,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If (CustAge &amp;lt;=20, 'AgeUnder20',&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If (CustAge&amp;gt;20 and CustAge &amp;lt;=30, 'Age20_30',&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;30 and CustAge &amp;lt;=40, 'Age30_40',&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;40 and CustAge &amp;lt;=50, 'Age40_50',&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;50 and CustAge &amp;lt;=60, 'Age50_60',&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If (CustAge &amp;gt;60 and CustAge &amp;lt;=70, 'Age60_70', 'Over70')))))) as AgeBand;&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; CustDateOfBirth,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Date (Floor(CustDateOfBirth), 'DD/MM/YYYY') as DobDate,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Year(Today(1))-Year(Date(CustDateOfBirth)) AS CustAge, // I suggest using age() function instead, which return the day accurate age&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustFirstTransaction,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustID;&lt;/P&gt;&lt;P&gt;SQL SELECT CustDateOfBirth,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustFirstTransaction,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; CustID&lt;/P&gt;&lt;P&gt;FROM *******;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2013 18:05:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542751#M1137499</guid>
      <dc:creator>swuehl</dc:creator>
      <dc:date>2013-10-10T18:05:25Z</dc:date>
    </item>
    <item>
      <title>Re: Re: Age range with If</title>
      <link>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542752#M1137500</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for the quick reply - I went with the if as a start point to establish whether to move fwd with the information although I do take the points covered in the answers.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Very much appreciate the help.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks again.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;P&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 10 Oct 2013 18:14:03 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Age-range-with-If/m-p/542752#M1137500</guid>
      <dc:creator>pauledrich</dc:creator>
      <dc:date>2013-10-10T18:14:03Z</dc:date>
    </item>
  </channel>
</rss>

