<?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: Formula Script - Weeks since Last Date worked in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Formula-Script-Weeks-since-Last-Date-worked/m-p/2498408#M102873</link>
    <description>&lt;P&gt;I want to make sure I understand your question correctly. It sounds like you’re asking for a way to calculate the &lt;STRONG&gt;weeks since the last (most recent) date&lt;/STRONG&gt; for each unique ID, in addition to your existing calculation for the first date.&lt;/P&gt;
&lt;P&gt;If that’s the case, you can try this adjustment to your script:&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE class="!overflow-visible"&gt;&lt;CODE class="!whitespace-pre hljs language-qlik"&gt;CandidateUniq as CandidateUniqID,

// Weeks since the first booked date
if(Max(Floor((Today() - WeekStart(BookingDate))/7))&amp;gt;=0, 
   Max(Floor((Today() - WeekStart(BookingDate))/7)), 
   0) as [WeeksSinceFirstBooked],

// Weeks since the last booked date
if(Floor((Today() - Max(BookingDate))/7)&amp;gt;=0, 
   Floor((Today() - Max(BookingDate))/7), 
   0) as [WeeksSinceLastBooked]

resident Bookings
Group By CandidateUniq;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will give you both:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;WeeksSinceFirstBooked&lt;/CODE&gt; – Weeks since the first date a unique ID appeared.&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;WeeksSinceLastBooked&lt;/CODE&gt; – Weeks since the last (most recent) date a unique ID appeared.&lt;/LI&gt;
&lt;/OL&gt;</description>
    <pubDate>Tue, 17 Dec 2024 20:54:37 GMT</pubDate>
    <dc:creator>nhenckel</dc:creator>
    <dc:date>2024-12-17T20:54:37Z</dc:date>
    <item>
      <title>Formula Script - Weeks since Last Date worked</title>
      <link>https://community.qlik.com/t5/App-Development/Formula-Script-Weeks-since-Last-Date-worked/m-p/2492503#M102430</link>
      <description>&lt;P&gt;I have a script formula that return the 1st date a unique ID appear, how do I add a script to get the weeks from the Last Date against that Unique ID?&lt;/P&gt;
&lt;P&gt;CandidateUniq as CandidateUniqID,&lt;/P&gt;
&lt;P&gt;if(Max(Floor((Today() - WeekStart(BookingDate))/7))&amp;gt;=0,Max(Floor((Today() - WeekStart(BookingDate))/7)),0) as [WeeksSinceFirstBooked]&lt;/P&gt;
&lt;P&gt;resident Bookings&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2024 11:25:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Formula-Script-Weeks-since-Last-Date-worked/m-p/2492503#M102430</guid>
      <dc:creator>OSCHPRO</dc:creator>
      <dc:date>2024-11-13T11:25:45Z</dc:date>
    </item>
    <item>
      <title>Re: Formula Script - Weeks since Last Date worked</title>
      <link>https://community.qlik.com/t5/App-Development/Formula-Script-Weeks-since-Last-Date-worked/m-p/2498408#M102873</link>
      <description>&lt;P&gt;I want to make sure I understand your question correctly. It sounds like you’re asking for a way to calculate the &lt;STRONG&gt;weeks since the last (most recent) date&lt;/STRONG&gt; for each unique ID, in addition to your existing calculation for the first date.&lt;/P&gt;
&lt;P&gt;If that’s the case, you can try this adjustment to your script:&lt;/P&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE class="!overflow-visible"&gt;&lt;CODE class="!whitespace-pre hljs language-qlik"&gt;CandidateUniq as CandidateUniqID,

// Weeks since the first booked date
if(Max(Floor((Today() - WeekStart(BookingDate))/7))&amp;gt;=0, 
   Max(Floor((Today() - WeekStart(BookingDate))/7)), 
   0) as [WeeksSinceFirstBooked],

// Weeks since the last booked date
if(Floor((Today() - Max(BookingDate))/7)&amp;gt;=0, 
   Floor((Today() - Max(BookingDate))/7), 
   0) as [WeeksSinceLastBooked]

resident Bookings
Group By CandidateUniq;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;This will give you both:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;&lt;CODE&gt;WeeksSinceFirstBooked&lt;/CODE&gt; – Weeks since the first date a unique ID appeared.&lt;/LI&gt;
&lt;LI&gt;&lt;CODE&gt;WeeksSinceLastBooked&lt;/CODE&gt; – Weeks since the last (most recent) date a unique ID appeared.&lt;/LI&gt;
&lt;/OL&gt;</description>
      <pubDate>Tue, 17 Dec 2024 20:54:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Formula-Script-Weeks-since-Last-Date-worked/m-p/2498408#M102873</guid>
      <dc:creator>nhenckel</dc:creator>
      <dc:date>2024-12-17T20:54:37Z</dc:date>
    </item>
  </channel>
</rss>

