<?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 Count Function in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Count-Function/m-p/1293869#M27323</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have three Dimension tables (Dates, Months and Stores) and one Fact table (Store Costs).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Dates} table has the below columns:&lt;/P&gt;&lt;P&gt;-- Date&lt;/P&gt;&lt;P&gt;--Day (1 to 31) as per the month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Months} has&lt;/P&gt;&lt;P&gt;--[Month]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Generic Date]&lt;/P&gt;&lt;P&gt;[Date]&lt;/P&gt;&lt;P&gt;[Month]&lt;/P&gt;&lt;P&gt;[Generic Date]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Stores} table has the below columns:&lt;/P&gt;&lt;P&gt;--Store Code&lt;/P&gt;&lt;P&gt;--Store Name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Store Costs] has the below columns:&lt;/P&gt;&lt;P&gt;[Generic Date] -- all the values are based on month&lt;/P&gt;&lt;P&gt;[Cost of Labor]&lt;/P&gt;&lt;P&gt;[Expenses]&lt;/P&gt;&lt;P&gt;[Store Code]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Sales]&lt;/P&gt;&lt;P&gt;[Generic Date] -- all the values are based on date&lt;/P&gt;&lt;P&gt;--[Generic Date]&lt;/P&gt;&lt;P&gt;-- Sales&lt;/P&gt;&lt;P&gt;--Cost of Sales&lt;/P&gt;&lt;P&gt;--Store Code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I designed a table to show the below value:&lt;/P&gt;&lt;P&gt;[Store Name]&lt;/P&gt;&lt;P&gt;[Sales MTD]&lt;/P&gt;&lt;P&gt;[Cost of Labor MTD]&lt;/P&gt;&lt;P&gt;[Expenses MTD}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Cost of Labor MTD} = [Cost of Labor] x (&amp;nbsp; $(vDaysCountMTD) / $(vDaysCountCM)]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vDaysCountMTD formula is as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If(getselectedcount([Month Year])&amp;lt;&amp;gt;1, &lt;/P&gt;&lt;P&gt;Count({$&amp;lt;[Date] = {"&amp;lt;=$(=Date(Today()-1))"}, [YearMonth No]= ,[Year] = ,[Month No]=,[Month Year]=,[Month]=,[MonthID]= {"$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}&amp;gt;} Distinct [Date Key])&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Count({$&amp;lt;[Date] = {"&amp;lt;=$(=Date(Today()-1))"}, [YearMonth No]= ,[Year] = ,[Month No]=,[MonthID]=,[Month]=,[Month Year]= {"$(=getfieldselections([Month Year]))"}&amp;gt;} Distinct [Date Key])&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vDaysCountCM =&lt;/P&gt;&lt;P&gt;If(getselectedcount([Month Year])&amp;lt;&amp;gt;1, &lt;BR /&gt;Count({$&amp;lt;[YearMonth No]= ,[Year] = ,[Month No]=,[Month Year]=,[Month]=,[MonthID]= {"$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}&amp;gt;} Distinct [Date Key])&lt;BR /&gt;,&lt;BR /&gt;Count({$&amp;lt;[YearMonth No]= ,[Year] = ,[Month No]=,[MonthID]=,[Month]=,[Month Year]= {"$(=getfieldselections([Month Year]))"}&amp;gt;} Distinct [Date Key])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I i run the dashboard the calculations were wrong. For some of the stores the vDaysCountCM gives 15 for some 31 and for some 10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should give 31 for all since the month has 31 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some stores the formula brings nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what I understands that it count on the Dates in the Sales table instead of the [Date] table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 22 Dec 2021 15:42:54 GMT</pubDate>
    <dc:creator>madnanansari</dc:creator>
    <dc:date>2021-12-22T15:42:54Z</dc:date>
    <item>
      <title>Count Function</title>
      <link>https://community.qlik.com/t5/App-Development/Count-Function/m-p/1293869#M27323</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I have three Dimension tables (Dates, Months and Stores) and one Fact table (Store Costs).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Dates} table has the below columns:&lt;/P&gt;&lt;P&gt;-- Date&lt;/P&gt;&lt;P&gt;--Day (1 to 31) as per the month.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Months} has&lt;/P&gt;&lt;P&gt;--[Month]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Generic Date]&lt;/P&gt;&lt;P&gt;[Date]&lt;/P&gt;&lt;P&gt;[Month]&lt;/P&gt;&lt;P&gt;[Generic Date]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Stores} table has the below columns:&lt;/P&gt;&lt;P&gt;--Store Code&lt;/P&gt;&lt;P&gt;--Store Name&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Store Costs] has the below columns:&lt;/P&gt;&lt;P&gt;[Generic Date] -- all the values are based on month&lt;/P&gt;&lt;P&gt;[Cost of Labor]&lt;/P&gt;&lt;P&gt;[Expenses]&lt;/P&gt;&lt;P&gt;[Store Code]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Sales]&lt;/P&gt;&lt;P&gt;[Generic Date] -- all the values are based on date&lt;/P&gt;&lt;P&gt;--[Generic Date]&lt;/P&gt;&lt;P&gt;-- Sales&lt;/P&gt;&lt;P&gt;--Cost of Sales&lt;/P&gt;&lt;P&gt;--Store Code&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I designed a table to show the below value:&lt;/P&gt;&lt;P&gt;[Store Name]&lt;/P&gt;&lt;P&gt;[Sales MTD]&lt;/P&gt;&lt;P&gt;[Cost of Labor MTD]&lt;/P&gt;&lt;P&gt;[Expenses MTD}&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;[Cost of Labor MTD} = [Cost of Labor] x (&amp;nbsp; $(vDaysCountMTD) / $(vDaysCountCM)]&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vDaysCountMTD formula is as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If(getselectedcount([Month Year])&amp;lt;&amp;gt;1, &lt;/P&gt;&lt;P&gt;Count({$&amp;lt;[Date] = {"&amp;lt;=$(=Date(Today()-1))"}, [YearMonth No]= ,[Year] = ,[Month No]=,[Month Year]=,[Month]=,[MonthID]= {"$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}&amp;gt;} Distinct [Date Key])&lt;/P&gt;&lt;P&gt;,&lt;/P&gt;&lt;P&gt;Count({$&amp;lt;[Date] = {"&amp;lt;=$(=Date(Today()-1))"}, [YearMonth No]= ,[Year] = ,[Month No]=,[MonthID]=,[Month]=,[Month Year]= {"$(=getfieldselections([Month Year]))"}&amp;gt;} Distinct [Date Key])&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;vDaysCountCM =&lt;/P&gt;&lt;P&gt;If(getselectedcount([Month Year])&amp;lt;&amp;gt;1, &lt;BR /&gt;Count({$&amp;lt;[YearMonth No]= ,[Year] = ,[Month No]=,[Month Year]=,[Month]=,[MonthID]= {"$(=((Year(Today()) -1)*12) + Num(Month(Today())))"}&amp;gt;} Distinct [Date Key])&lt;BR /&gt;,&lt;BR /&gt;Count({$&amp;lt;[YearMonth No]= ,[Year] = ,[Month No]=,[MonthID]=,[Month]=,[Month Year]= {"$(=getfieldselections([Month Year]))"}&amp;gt;} Distinct [Date Key])&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I i run the dashboard the calculations were wrong. For some of the stores the vDaysCountCM gives 15 for some 31 and for some 10.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;It should give 31 for all since the month has 31 days.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;For some stores the formula brings nothing.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;what I understands that it count on the Dates in the Sales table instead of the [Date] table.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 22 Dec 2021 15:42:54 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Count-Function/m-p/1293869#M27323</guid>
      <dc:creator>madnanansari</dc:creator>
      <dc:date>2021-12-22T15:42:54Z</dc:date>
    </item>
  </channel>
</rss>

