<?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: Year Before comparison doesn't work fully for a selected period in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Year-Before-comparison-doesn-t-work-fully-for-a-selected-period/m-p/2492507#M102198</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May have a look to this post&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.qreatic.fr/dailyqlikchallenge/2021/6/04/69-same-day-previous-year-comparison-in-qlik-sense" target="_self"&gt;https://www.qreatic.fr/dailyqlikchallenge/2021/6/04/69-same-day-previous-year-comparison-in-qlik-sense&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The trick is to create a pivot calendar in the script between your calendar table and fact table :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brunobertels_0-1731497990078.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/174300i4E88DB835920B34A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brunobertels_0-1731497990078.png" alt="brunobertels_0-1731497990078.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class=""&gt;Load script to generate it from Facts :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Pivot:
Load distinct Date_ID as Date_ID, 
	 Date_ID as Date_Cal,
	 'P' as TypeDate
resident Sales;
Load distinct Date_ID-364 as Date_ID, 
	 Date_ID as Date_Cal,
	 'SameDay' as TypeDate
resident Sales;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then adapt your mesure for previous year with set analysis :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;Current Year : Sum({$&amp;lt;TypeDate={'P'}&amp;gt;}Sales)&lt;/P&gt;
&lt;P class=""&gt;Same Day previous year : Sum({$&amp;lt;TypeDate={'SameDay'}&amp;gt;}Sales)&lt;/P&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;Hope it helps&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 13 Nov 2024 11:41:10 GMT</pubDate>
    <dc:creator>brunobertels</dc:creator>
    <dc:date>2024-11-13T11:41:10Z</dc:date>
    <item>
      <title>Year Before comparison doesn't work fully for a selected period</title>
      <link>https://community.qlik.com/t5/App-Development/Year-Before-comparison-doesn-t-work-fully-for-a-selected-period/m-p/2492449#M102190</link>
      <description>&lt;P&gt;Hello, Qlik community!&lt;/P&gt;
&lt;P&gt;I have a line chart with 3 measures, the last measure is comparison with Year Before. Currently the Year Before line shows only the year before direct purchases for 2022 and as you cans see the red line in 2023 is null, which should show 2022 data. The years can be chosen from a date filter.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Stanislav1_0-1731485138970.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/174282i0F1930D3D51488F0/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Stanislav1_0-1731485138970.png" alt="Stanislav1_0-1731485138970.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The calculation behind this is complex and the mistake might be in either the dimension or the measure expression. This is the dimensions expression:&amp;nbsp;=If($(vL.UI.time.Field)&amp;gt;=vL.time.From,Date([#$(vL.UI.time.Field)], 'DD MMM'),Date([#$(vL.UI.time.Field)]+$(vL.time.ToShift),'DD MMM'))&lt;/P&gt;
&lt;P&gt;Measure expression:&amp;nbsp;&lt;/P&gt;
&lt;DIV&gt;=if(vL.selected.Measure.Chart='$ After-trial purchases',Num([msr11 (Compare)],'$ # ##0'),&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; if(vL.selected.Measure.Chart='$ Direct purchases', Num([msr08 (Compare)],'$ # ##0'),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; if(vL.selected.Measure.Chart='$ One-off purchases', Num([msr15 (Compare)],'$ # ##0'),&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(vL.selected.Measure.Chart='$ Renewals', Num([msr33 (Compare)],'$ # ##0'),&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(vL.selected.Measure.Chart='$ App purchases', Num([msr59(Compare)],'$ # ##0'),&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if(vL.selected.Measure.Chart='$ Report corrections', Num([$ RC (Compare)],'$ # ##0'),&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if(vL.selected.Measure.Chart='$ Total FR',Num([msr107 (Compare)],'$ # ##0'),Num([msr11 (Compare)],'$ # ##0'))))))))&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I suspect that this issue will be in the dimension expression, because the selected period covers the same dates in two different years.&amp;nbsp; How can I correct the code to distribute the data in both years, in this case 2022 and 2023&amp;nbsp; and the year before data (for 2023 show 2022 and for 2022 show 2021)&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;I am open to any suggestions and if you need any additional information I can provide it.&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Wed, 13 Nov 2024 08:20:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Year-Before-comparison-doesn-t-work-fully-for-a-selected-period/m-p/2492449#M102190</guid>
      <dc:creator>Stanislav1</dc:creator>
      <dc:date>2024-11-13T08:20:13Z</dc:date>
    </item>
    <item>
      <title>Re: Year Before comparison doesn't work fully for a selected period</title>
      <link>https://community.qlik.com/t5/App-Development/Year-Before-comparison-doesn-t-work-fully-for-a-selected-period/m-p/2492507#M102198</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;May have a look to this post&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://www.qreatic.fr/dailyqlikchallenge/2021/6/04/69-same-day-previous-year-comparison-in-qlik-sense" target="_self"&gt;https://www.qreatic.fr/dailyqlikchallenge/2021/6/04/69-same-day-previous-year-comparison-in-qlik-sense&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The trick is to create a pivot calendar in the script between your calendar table and fact table :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="brunobertels_0-1731497990078.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/174300i4E88DB835920B34A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="brunobertels_0-1731497990078.png" alt="brunobertels_0-1731497990078.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P class=""&gt;Load script to generate it from Facts :&lt;/P&gt;
&lt;PRE&gt;&lt;CODE&gt;Pivot:
Load distinct Date_ID as Date_ID, 
	 Date_ID as Date_Cal,
	 'P' as TypeDate
resident Sales;
Load distinct Date_ID-364 as Date_ID, 
	 Date_ID as Date_Cal,
	 'SameDay' as TypeDate
resident Sales;&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;then adapt your mesure for previous year with set analysis :&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;Current Year : Sum({$&amp;lt;TypeDate={'P'}&amp;gt;}Sales)&lt;/P&gt;
&lt;P class=""&gt;Same Day previous year : Sum({$&amp;lt;TypeDate={'SameDay'}&amp;gt;}Sales)&lt;/P&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;Hope it helps&amp;nbsp;&lt;/P&gt;
&lt;P class=""&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2024 11:41:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Year-Before-comparison-doesn-t-work-fully-for-a-selected-period/m-p/2492507#M102198</guid>
      <dc:creator>brunobertels</dc:creator>
      <dc:date>2024-11-13T11:41:10Z</dc:date>
    </item>
    <item>
      <title>Re: Year Before comparison doesn't work fully for a selected period</title>
      <link>https://community.qlik.com/t5/App-Development/Year-Before-comparison-doesn-t-work-fully-for-a-selected-period/m-p/2492534#M102202</link>
      <description>&lt;P&gt;Thank you for your suggestion, but it doesn't help for this issue&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 13 Nov 2024 13:59:59 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Year-Before-comparison-doesn-t-work-fully-for-a-selected-period/m-p/2492534#M102202</guid>
      <dc:creator>Stanislav1</dc:creator>
      <dc:date>2024-11-13T13:59:59Z</dc:date>
    </item>
  </channel>
</rss>

