<?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: Count(MonthYear) Returns unexpected Values in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899184#M74220</link>
    <description>&lt;P&gt;Hi Henric, Thank you for your Help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes you are just looking too long at the same Line without seeing anything....&lt;/P&gt;
&lt;P&gt;I also appreciate your Feedback regarding the MasterCalendar. Looking great now!&lt;/P&gt;</description>
    <pubDate>Wed, 02 Mar 2022 09:43:12 GMT</pubDate>
    <dc:creator>senior_freshmen</dc:creator>
    <dc:date>2022-03-02T09:43:12Z</dc:date>
    <item>
      <title>Count(MonthYear) Returns unexpected Values</title>
      <link>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899127#M74214</link>
      <description>&lt;P&gt;Hello,&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm trying to understand why I'm receiving wrong Results with a &lt;EM&gt;COUNT()&lt;/EM&gt; Function.&lt;/P&gt;
&lt;P&gt;Following Table is filled with the Source Data:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;ID&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;DATE&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;TIME&amp;nbsp;&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Content&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;1&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;01.01.2022&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;14:00:36&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;XXX&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;2&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;01.03.2022&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;09:35:14&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;YYY&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="26px"&gt;3&lt;/TD&gt;
&lt;TD height="26px"&gt;05.03.2022&lt;/TD&gt;
&lt;TD height="26px"&gt;10:50:00&lt;/TD&gt;
&lt;TD height="26px"&gt;JAH&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD height="25px"&gt;4&lt;/TD&gt;
&lt;TD height="25px"&gt;08.03.2022&lt;/TD&gt;
&lt;TD height="25px"&gt;18:37:00&lt;/TD&gt;
&lt;TD height="25px"&gt;JJS&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This Table I have connected with a Master Calendar:&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;QuartersMap:  
MAPPING LOAD   
rowno() as Month,  
'Q' &amp;amp; Ceil (rowno()/3) as Quarter  
AUTOGENERATE (12);  
      
Temp:  
Load  
min(Date) as minDate,  
max(Date) as maxDate  
Resident LessonsLearned;  
      
Let varMinDate = Num(Peek('minDate', 0, 'Temp'));  
Let varMaxDate = Num(Peek('maxDate', 0, 'Temp'));  
   
TempCalendar:  
LOAD  
$(varMinDate) + Iterno()-1 As Num,  
Date($(varMinDate) + IterNo() - 1) as TempDate AutoGenerate 1 While $(varMinDate) + IterNo() -1 &amp;lt;= $(varMaxDate);
      
MasterCalendar:  
Load  
  TempDate AS Date,  
  week(TempDate) As Week,  
  Year(TempDate) As Year,  
  Month(TempDate) As Month,  
  Day(TempDate) As Day,  
  ApplyMap('QuartersMap', month(TempDate), Null()) as Quarter,  
  Week(weekstart(TempDate)) &amp;amp; '-' &amp;amp; WeekYear(TempDate) as WeekYear,  
  WeekDay(TempDate) as WeekDay, 
  (Date(monthstart(TempDate), 'MMM-YY')) AS MonthYear,
  If(TempDate &amp;lt;= Today() And TempDate &amp;gt;= SetDateYear(Today(), Year(Today())-1), 1, 0) As Last12Months
Resident TempCalendar  
Order By TempDate ASC;  

Drop Table TempCalendar;  
DROP Table Temp;  
&lt;/LI-CODE&gt;
&lt;P&gt;So far so good, the Tables are correctly connected via the Date Field:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="senior_freshmen_0-1646208238190.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/73336i411B156C9AD419BC/image-size/medium?v=v2&amp;amp;px=400" role="button" title="senior_freshmen_0-1646208238190.png" alt="senior_freshmen_0-1646208238190.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;But when I Try to count ID Values with MonthYear, I receive unexpected Values:&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Expected&lt;/STRONG&gt;: 3 (Like in my Example)&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;STRONG&gt;Actual&lt;/STRONG&gt;: 1,17&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="senior_freshmen_1-1646208307515.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/73337i705DAC3D5C2AC7E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="senior_freshmen_1-1646208307515.png" alt="senior_freshmen_1-1646208307515.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="senior_freshmen_2-1646208347017.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/73338i612195F8C7CFB888/image-size/medium?v=v2&amp;amp;px=400" role="button" title="senior_freshmen_2-1646208347017.png" alt="senior_freshmen_2-1646208347017.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;This is how I configured this Table.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Has anyone an idea what I am doing wrong?&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 08:07:49 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899127#M74214</guid>
      <dc:creator>senior_freshmen</dc:creator>
      <dc:date>2022-03-02T08:07:49Z</dc:date>
    </item>
    <item>
      <title>Re: Count(MonthYear) Returns unexpected Values</title>
      <link>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899160#M74216</link>
      <description>&lt;P&gt;You are using a Moving average...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Henric_Cronstrm_1-1646211501360.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/73351i927C52E7C5E5B5E3/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Henric_Cronstrm_1-1646211501360.png" alt="Henric_Cronstrm_1-1646211501360.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 08:58:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899160#M74216</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2022-03-02T08:58:28Z</dc:date>
    </item>
    <item>
      <title>Re: Count(MonthYear) Returns unexpected Values</title>
      <link>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899175#M74217</link>
      <description>&lt;P&gt;By the way, try the following Master Calendar instead. It does the same, but is faster and cleaner: No mapping table. No variables. No temp tables.&lt;/P&gt;&lt;P&gt;MasterCalendar:&lt;BR /&gt;Load&lt;BR /&gt;Year(Date) as Year,&lt;BR /&gt;Month(Date) as Month,&lt;BR /&gt;Day(Date) as Day,&lt;BR /&gt;Dual('Q'&amp;amp;Ceil(Month(Date)/3), Ceil(Month(Date)/3)) as Quarter,&lt;BR /&gt;Week(Date) as Week,&lt;BR /&gt;Week(Weekstart(Date)) &amp;amp; '-' &amp;amp; WeekYear(Date) as WeekYear,&lt;BR /&gt;WeekDay(Date) as WeekDay,&lt;BR /&gt;Date(Monthstart(Date), 'MMM-YY') as MonthYear,&lt;BR /&gt;If(Date&amp;lt;=Today() And Date&amp;gt;AddYears(Today(),-1),1,0) as Last12Months,&lt;BR /&gt;Date;&lt;BR /&gt;Load // ------------ generate all dates between smallest and largest date ------------&lt;BR /&gt;Date( CalendarBegin+Iterno()-1 ) as Date&lt;BR /&gt;While CalendarBegin+Iterno()-1&amp;lt;=CalendarEnd;&lt;BR /&gt;Load // ------ find smallest and largest value in symbol table; extend to full years ------&lt;BR /&gt;YearStart(Min(Fieldvalue('Date',RecNo()))) as CalendarBegin,&lt;BR /&gt;YearEnd( Max(Fieldvalue('Date',RecNo()))) as CalendarEnd&lt;BR /&gt;Autogenerate FieldValueCount('Date');&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 09:28:46 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899175#M74217</guid>
      <dc:creator>hic</dc:creator>
      <dc:date>2022-03-02T09:28:46Z</dc:date>
    </item>
    <item>
      <title>Re: Count(MonthYear) Returns unexpected Values</title>
      <link>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899184#M74220</link>
      <description>&lt;P&gt;Hi Henric, Thank you for your Help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sometimes you are just looking too long at the same Line without seeing anything....&lt;/P&gt;
&lt;P&gt;I also appreciate your Feedback regarding the MasterCalendar. Looking great now!&lt;/P&gt;</description>
      <pubDate>Wed, 02 Mar 2022 09:43:12 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Count-MonthYear-Returns-unexpected-Values/m-p/1899184#M74220</guid>
      <dc:creator>senior_freshmen</dc:creator>
      <dc:date>2022-03-02T09:43:12Z</dc:date>
    </item>
  </channel>
</rss>

