<?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 Calculate Previous completed week total sales in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Calculate-Previous-completed-week-total-sales/m-p/2526702#M107285</link>
    <description>&lt;P&gt;I am using the following dimensions to calculate previous week sales in Pivot table. Also by default we have WeekEnd_Date trigger set to max Week EndDate. Based on the selection it should change.&lt;/P&gt;
&lt;P&gt;Variable is already defined :&amp;nbsp;=Date(max (WE_Date)-7,'MM/DD/YY')&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Dimesnion 1: =ValueList('Prior Week Sales','Prior Week Cases','Prior Week Case Cost')&lt;BR /&gt;prior week sales dimension 2&lt;BR /&gt;=ValueList(&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 6, 'MM/DD/YY'), // Sunday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 5, 'MM/DD/YY'), // Monday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 4, 'MM/DD/YY'), // Tuesday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 3, 'MM/DD/YY'), // Wednesday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 2, 'MM/DD/YY'), // Thursday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 1, 'MM/DD/YY'), // Friday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY'), 'MM/DD/YY') // Saturday&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;Expression :&lt;/P&gt;
&lt;P&gt;Pick(&lt;BR /&gt;Match(&lt;BR /&gt;ValueList(&lt;BR /&gt;'Prior Week Sales','Prior Week Products','Prior Week Product Cost'&lt;BR /&gt;),&lt;BR /&gt;'Prior Week Sales','Prior Week Products','Prior Week Product Cost'&lt;/P&gt;
&lt;P&gt;),&lt;BR /&gt;Sum(sales_amount), Sum(Product_Cost), Sum( sales_amount) /Alt(Sum( Product_Cost), 0))&lt;/P&gt;
&lt;P&gt;But, Getting the same values for the entire dates. Images attached&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="qvqs_0-1754652030352.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/182649i1260EE7F578374EC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="qvqs_0-1754652030352.png" alt="qvqs_0-1754652030352.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 08 Aug 2025 11:23:41 GMT</pubDate>
    <dc:creator>qvqs</dc:creator>
    <dc:date>2025-08-08T11:23:41Z</dc:date>
    <item>
      <title>Calculate Previous completed week total sales</title>
      <link>https://community.qlik.com/t5/App-Development/Calculate-Previous-completed-week-total-sales/m-p/2526702#M107285</link>
      <description>&lt;P&gt;I am using the following dimensions to calculate previous week sales in Pivot table. Also by default we have WeekEnd_Date trigger set to max Week EndDate. Based on the selection it should change.&lt;/P&gt;
&lt;P&gt;Variable is already defined :&amp;nbsp;=Date(max (WE_Date)-7,'MM/DD/YY')&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;Dimesnion 1: =ValueList('Prior Week Sales','Prior Week Cases','Prior Week Case Cost')&lt;BR /&gt;prior week sales dimension 2&lt;BR /&gt;=ValueList(&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 6, 'MM/DD/YY'), // Sunday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 5, 'MM/DD/YY'), // Monday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 4, 'MM/DD/YY'), // Tuesday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 3, 'MM/DD/YY'), // Wednesday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 2, 'MM/DD/YY'), // Thursday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY') - 1, 'MM/DD/YY'), // Friday&lt;BR /&gt;Date(Date#('$(vPreviousWeekEnd)', 'MM/DD/YY'), 'MM/DD/YY') // Saturday&lt;BR /&gt;)&lt;/P&gt;
&lt;P&gt;Expression :&lt;/P&gt;
&lt;P&gt;Pick(&lt;BR /&gt;Match(&lt;BR /&gt;ValueList(&lt;BR /&gt;'Prior Week Sales','Prior Week Products','Prior Week Product Cost'&lt;BR /&gt;),&lt;BR /&gt;'Prior Week Sales','Prior Week Products','Prior Week Product Cost'&lt;/P&gt;
&lt;P&gt;),&lt;BR /&gt;Sum(sales_amount), Sum(Product_Cost), Sum( sales_amount) /Alt(Sum( Product_Cost), 0))&lt;/P&gt;
&lt;P&gt;But, Getting the same values for the entire dates. Images attached&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="qvqs_0-1754652030352.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/182649i1260EE7F578374EC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="qvqs_0-1754652030352.png" alt="qvqs_0-1754652030352.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 11:23:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculate-Previous-completed-week-total-sales/m-p/2526702#M107285</guid>
      <dc:creator>qvqs</dc:creator>
      <dc:date>2025-08-08T11:23:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculate Previous completed week total sales</title>
      <link>https://community.qlik.com/t5/App-Development/Calculate-Previous-completed-week-total-sales/m-p/2526735#M107286</link>
      <description>&lt;P&gt;Your aggregations have no relations to the dates - which are just a plotted free-text within the table.&lt;/P&gt;&lt;P&gt;Even if it's technically possible to create calculated dimensions in the UI - it shouldn't be done unless there is no other way. Else recommended is to move the logic or at least the essential parts into the data-model.&lt;/P&gt;&lt;P&gt;In your case there are various ways to use native fields to define the target. The most simple one would be just to use the weekday from the calendar as dimension and to add the condition to the previous week within the expression in a set analysis, maybe like:&lt;/P&gt;&lt;P&gt;sum({&amp;lt; RunningWeek = {"$(=max(RunningWeek)-1)"}&amp;gt;} Field)&lt;/P&gt;&lt;P&gt;Nearly all thinkable information about any period-relationship are applicable within a calendar and by using&amp;nbsp;&lt;A href="https://community.qlik.com/t5/Design/The-As-Of-Table/ba-p/1466130" target="_blank"&gt;The As-Of Table - Qlik Community - 1466130&lt;/A&gt;&amp;nbsp;all kinds of overlapping logic became quite easy to implement.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 08 Aug 2025 14:45:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Calculate-Previous-completed-week-total-sales/m-p/2526735#M107286</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2025-08-08T14:45:45Z</dc:date>
    </item>
  </channel>
</rss>

