<?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: Duplicate data on a nonexistent date ? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106884#M90405</link>
    <description>&lt;P&gt;since there are no readings from 8/4 to 8/9 then the odometer reading didnt change - stays at what was read in 8/3&lt;/P&gt;</description>
    <pubDate>Thu, 17 Aug 2023 18:10:16 GMT</pubDate>
    <dc:creator>edwin</dc:creator>
    <dc:date>2023-08-17T18:10:16Z</dc:date>
    <item>
      <title>Duplicate data on a nonexistent date ?</title>
      <link>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106429#M90340</link>
      <description>&lt;P&gt;Hello everyone,&lt;/P&gt;
&lt;P&gt;Could you please give me your opinion on the following case, I've tried a few tips found on this site but I'm still struggling to find the solution.&lt;/P&gt;
&lt;P&gt;I want to retrieve the odometers of my vehicles at the end of each year (31/12/YYYY).&lt;/P&gt;
&lt;P&gt;However, some years, when the vehicle doesn't run at all, no line goes up. So I need to duplicate the previous year's information.&lt;/P&gt;
&lt;P&gt;Here's how I proceed:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="2"&gt;DIM_PARC_KM:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;LOAD&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;_KEY_Parc_Id AS Parc_ID,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;"KM Compteur",&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Year("Date") as ANNEE,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Date("Date") as "Date"&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;FROM DIM_PARC_KM&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Then I used this script that I found on this site :&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="2"&gt;MASTER_CALENDAR: &lt;BR /&gt;//Procedure MasterCalendar:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;//1. Extract the Minimum and Maximum dates from a date column in the fact table. From the existing table, you create min and max.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Min_Max:&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Load&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Min("Date") as MinDate,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Max("Date") as MaxDate&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Resident DIM_PARC_KM;&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;//2. Populate all the dates between the min and max dates using peek function.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Let vMinDate = Peek('MinDate',0,'Min_Max');&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Let vMaxDate = Peek('MaxDate',0,'Min_Max');&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;// Note: after that drop Min_Max temporary table.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Drop Table Min_Max;&lt;BR /&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;//3. Extract all the necessary date columns required for the dashboards&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;// Pulling dates between Min date and MAx Date&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;&lt;BR /&gt;Master_Calendar:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Load *,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Year("Date") as Year,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Month("Date") as Month;&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;//4. Associate the date column in the fact table to the date column in the master calendar.&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Load&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Date($(vMinDate) + IterNo() - 1) as "Date"&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;AutoGenerate 1&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;While $(vMinDate) + IterNo() - 1 &amp;lt;= $(vMaxDate);&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;//This is one of the processes for creating a master calendar.&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;&lt;BR /&gt;And my last section, where I am trying to fill the data :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&lt;FONT size="2"&gt;DATE_FILLING:&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;NoConcatenate &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Load "Date,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Parc_ID,&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;If( IsNull( "KM Compteur" ), Peek( "KM Compteur", -"Date" ), "KM Compteur" ) as "KM Compteur1"&lt;/FONT&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Resident DIM_PARC_KM&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Order By "Date" ; // so that above values can be propagated downwards&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="2"&gt;Drop Table DIM_PARC_KM;&lt;/FONT&gt;&lt;/PRE&gt;
&lt;P&gt;Any ideas about the mistake made?&lt;/P&gt;
&lt;P&gt;Any help would be greatly appreciated!&amp;nbsp; &amp;nbsp;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Thanks !&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Aug 2023 15:39:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106429#M90340</guid>
      <dc:creator>MDE_PF</dc:creator>
      <dc:date>2023-08-16T15:39:13Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate data on a nonexistent date ?</title>
      <link>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106878#M90403</link>
      <description>&lt;P&gt;is&amp;nbsp;"KM Compteur" the KMs travelled for the date or the odometer reading for the date.&amp;nbsp; &amp;nbsp;those are two diff things.&amp;nbsp; the odometer reading is the accumulation of the KMs travelled.&amp;nbsp; the solution i suggest is to create a bridge between your fact and your calendar that when a user selects a date - it is associated to all the KMs prior to that date and you can just sum(KMs) to get the odometer reading.&amp;nbsp; or if your fact contains the odometer reading for that date (and in some dates you dont have an odometer reading) i would associate the date to the last odometer reading prior or equal to that date so your expression would just be only(ODOMETERREADING)&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 17:52:25 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106878#M90403</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2023-08-17T17:52:25Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate data on a nonexistent date ?</title>
      <link>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106883#M90404</link>
      <description>&lt;P&gt;the following assumes you have odometer reading:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;NoConcatenate
KMs:
load *, ID &amp;amp; '|' &amp;amp; date_read as key inline [
ID, odometer_reading, date_read
1, 50000, 8/1/2023
1, 51000, 8/2/2023
1, 52500, 8/3/2023
1, 60000, 8/10/2023
];

NoConcatenate
Calendar:
load date(date('8/1/2023')+iterno()-1) as date while date(date('8/1/2023')+iterno()-1)&amp;lt;=date('8/10/2023');
load 1 AutoGenerate(1);

NoConcatenate
tmpBridge:
load key,
ID,
date_read
Resident KMs;

inner join (tmpBridge)
load date Resident Calendar;



NoConcatenate
tmpBridge2:
load ID,
key,
date_read,
date
Resident tmpBridge
where date &amp;gt;= date_read;

drop table tmpBridge;

inner join (tmpBridge2)
load ID, date(max(date_read)) as date_read, date
Resident tmpBridge2
group by ID, date;


NoConcatenate
Bridge:
load key, date Resident tmpBridge2;

drop table tmpBridge2;
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is the DM:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_0-1692295693615.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/114661i21DD8088B75E6934/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_0-1692295693615.png" alt="edwin_0-1692295693615.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;this is a sample output:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="edwin_1-1692295754849.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/114662i263479DC803E819A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="edwin_1-1692295754849.png" alt="edwin_1-1692295754849.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 18:09:22 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106883#M90404</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2023-08-17T18:09:22Z</dc:date>
    </item>
    <item>
      <title>Re: Duplicate data on a nonexistent date ?</title>
      <link>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106884#M90405</link>
      <description>&lt;P&gt;since there are no readings from 8/4 to 8/9 then the odometer reading didnt change - stays at what was read in 8/3&lt;/P&gt;</description>
      <pubDate>Thu, 17 Aug 2023 18:10:16 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Duplicate-data-on-a-nonexistent-date/m-p/2106884#M90405</guid>
      <dc:creator>edwin</dc:creator>
      <dc:date>2023-08-17T18:10:16Z</dc:date>
    </item>
  </channel>
</rss>

