<?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: Calculate the difference between two numbers and Group the product in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1523160#M749493</link>
    <description>&lt;P&gt;Would you be able to share the Excel file - Test Data.xlsx? Also, can you provide the expected output from the data you will provide in the Excel&lt;/P&gt;</description>
    <pubDate>Thu, 20 Dec 2018 17:33:35 GMT</pubDate>
    <dc:creator>sunny_talwar</dc:creator>
    <dc:date>2018-12-20T17:33:35Z</dc:date>
    <item>
      <title>Calculate the difference between two numbers and Group the product</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1522678#M749489</link>
      <description>&lt;P&gt;I have been trying to calculate the difference between two dates and group the numeric output in different ways.&amp;nbsp; I have found a way that works but is completely slow and complicated. &amp;nbsp;&lt;/P&gt;&lt;P&gt;Ideally I would like to&lt;/P&gt;&lt;P&gt;(1) create a field called 'Days Since Due' by subtracting [Today()] - [Due_Date].&lt;/P&gt;&lt;P&gt;(2) group the output of the above formula by '0 to 30', '30 to 60', '60 to 90', and '90+'.&lt;/P&gt;&lt;P&gt;I think this is what I want but I couldn't get it to work:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') as Date_Due_Converted_to_Date,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) as Date_Due_Converted_to_Number,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num(date(today(),'DD/MM/YYYY')) as Date_Today,&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY')) as Days_Since_today,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;if(Days_Since_today&amp;lt;0,&lt;BR /&gt;&amp;nbsp; if((Days_Since_today&amp;lt;=-1 and Days_Since_today&amp;gt;=-30),'30',&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if((Days_Since_today&amp;lt;=-31 and Days_Since_today&amp;gt;=-60),'30 to 60',&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if((Days_Since_today&amp;lt;=-61 and Days_Since_today&amp;gt;=-90),'60 to 90','+90')))) as OpenDaysPastDue,&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I expanded it to this which works&amp;nbsp; but is slow&amp;nbsp; because it's so complex:&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;if(num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY'))&amp;lt;0,&lt;BR /&gt;&amp;nbsp; if((num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY'))&amp;lt;=-1&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; and num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY'))&amp;gt;=-30),'30',&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if((num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY'))&amp;lt;=-31&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; and num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY'))&amp;gt;=-60),'30 to 60',&lt;BR /&gt;&amp;nbsp; &amp;nbsp;if((num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY'))&amp;lt;=-61&lt;BR /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp; and num(date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') ) - num(date(today(),'DD/MM/YYYY'))&amp;gt;=-90),'60 to 90','+90')))) as OpenDaysPastDue,&lt;/P&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 16:16:04 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1522678#M749489</guid>
      <dc:creator>leale1997</dc:creator>
      <dc:date>2020-11-25T16:16:04Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two numbers and Group the product</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1522681#M749490</link>
      <description>&lt;P&gt;The complexity should not lead to it's slowness... but in order to avoid the complexity... you can do a preceding load like this&lt;/P&gt;&lt;PRE&gt;LOAD *,
 If(Days_Since_today&amp;lt;0,
  If((Days_Since_today&amp;lt;=-1 and Days_Since_today&amp;gt;=-30),'30',
   If((Days_Since_today&amp;lt;=-31 and Days_Since_today&amp;gt;=-60),'30 to 60',
   If((Days_Since_today&amp;lt;=-61 and Days_Since_today&amp;gt;=-90),'60 to 90','+90')))) as OpenDaysPastDue;
&lt;BR /&gt;LOAD Date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') as Date_Due_Converted_to_Date,
     Num(Date#([Date_Due],'MM/DD/YYYY')) as Date_Due_Converted_to_Number,
     Num(Today()) as Date_Today,
     Date#([Date_Due], 'MM/DD/YYYY') - Today() as Days_Since_today
FROM ....;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 17:09:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1522681#M749490</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-19T17:09:32Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two numbers and Group the product</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1522683#M749491</link>
      <description>&lt;P&gt;But you can also do this&lt;/P&gt;&lt;PRE&gt;LOAD Date(Date#([Date_Due],'MM/DD/YYYY'),'DD/MM/YYYY') as Date_Due_Converted_to_Date,
     Num(Date#([Date_Due],'MM/DD/YYYY')) as Date_Due_Converted_to_Number,
     Num(Today()) as Date_Today,
     Date#([Date_Due], 'MM/DD/YYYY') - Today() as Days_Since_today,
     If((Date#([Date_Due], 'MM/DD/YYYY') - Today()) &amp;lt; 0,
     If(((Date#([Date_Due], 'MM/DD/YYYY') - Today()) &amp;gt;= -30), '30',
     If(((Date#([Date_Due], 'MM/DD/YYYY') - Today()) &amp;gt;= -60), '30 to 60',
     If(((Date#([Date_Due], 'MM/DD/YYYY') - Today()) &amp;gt;= -90), '60 to 90', '+90')))) as OpenDaysPastDue
FROM ....;&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Dec 2018 17:13:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1522683#M749491</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-19T17:13:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two numbers and Group the product</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1523150#M749492</link>
      <description>&lt;P&gt;I'm still kind of stuck on this one. &amp;nbsp;&lt;/P&gt;&lt;P&gt;I am attaching a test file hoping it will help me describe my intent.&lt;/P&gt;&lt;P&gt;I would like to calculate the difference between two numbers.&amp;nbsp; due_date - today()&lt;/P&gt;&lt;P&gt;And then take the product of that calculation and group it.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Between -1 and -30 = '30'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Between -31 and -60 = '60'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Between -61 and -90 = '60'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;GT -90 = '90+'&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 17:18:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1523150#M749492</guid>
      <dc:creator>leale1997</dc:creator>
      <dc:date>2018-12-20T17:18:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two numbers and Group the product</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1523160#M749493</link>
      <description>&lt;P&gt;Would you be able to share the Excel file - Test Data.xlsx? Also, can you provide the expected output from the data you will provide in the Excel&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 17:33:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1523160#M749493</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2018-12-20T17:33:35Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate the difference between two numbers and Group the product</title>
      <link>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1523178#M749494</link>
      <description>&lt;P&gt;Attached is the excel file. &amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like the output of the field 'Days_Since_Today' to align with the output in field 'OpenDaysPastDue'.&lt;/P&gt;&lt;P&gt;'Days_Since_Today' is the calculated field.&amp;nbsp; 'OpenDaysPastDue' is the grouped field. (30,60,90,90+)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the assist :0)&lt;/P&gt;</description>
      <pubDate>Thu, 20 Dec 2018 17:51:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Calculate-the-difference-between-two-numbers-and-Group-the/m-p/1523178#M749494</guid>
      <dc:creator>leale1997</dc:creator>
      <dc:date>2018-12-20T17:51:07Z</dc:date>
    </item>
  </channel>
</rss>

