<?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 Expression for New Customers Each Month in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Expression-for-New-Customers-Each-Month/m-p/2160150#M94092</link>
    <description>&lt;P&gt;I searched the community for this and asked some of my &lt;SPAN&gt;colleagues, but was not able to get an answer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I know I could create a flag on the import script, but this is a large dashboard used by multiple teams. I don't want to change to script for one project out of hundreds. I will do it if it is the only option.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is there a was to get in the expression new customers monthly?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My data is pretty simple:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;CustomerID and SalesDate&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want a bar chart for new customers monthly, basically using the customers minimum sales data as the month they are considered a new customer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Right now I am just counting the unique customers, because I have tried a few things and nothing has worked.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="datagrrl_1-1704901466418.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/126831iF63557F0B46DA8DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="datagrrl_1-1704901466418.png" alt="datagrrl_1-1704901466418.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The results should be closer to this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="datagrrl_0-1704901385844.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/126830i6A07BAA567405274/image-size/medium?v=v2&amp;amp;px=400" role="button" title="datagrrl_0-1704901385844.png" alt="datagrrl_0-1704901385844.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Any assistance is appreciated. I have attached a mocked up app.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 10 Jan 2024 15:48:09 GMT</pubDate>
    <dc:creator>datagrrl</dc:creator>
    <dc:date>2024-01-10T15:48:09Z</dc:date>
    <item>
      <title>Expression for New Customers Each Month</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-for-New-Customers-Each-Month/m-p/2160150#M94092</link>
      <description>&lt;P&gt;I searched the community for this and asked some of my &lt;SPAN&gt;colleagues, but was not able to get an answer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I know I could create a flag on the import script, but this is a large dashboard used by multiple teams. I don't want to change to script for one project out of hundreds. I will do it if it is the only option.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Is there a was to get in the expression new customers monthly?&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;My data is pretty simple:&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;CustomerID and SalesDate&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;I want a bar chart for new customers monthly, basically using the customers minimum sales data as the month they are considered a new customer.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Right now I am just counting the unique customers, because I have tried a few things and nothing has worked.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="datagrrl_1-1704901466418.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/126831iF63557F0B46DA8DB/image-size/medium?v=v2&amp;amp;px=400" role="button" title="datagrrl_1-1704901466418.png" alt="datagrrl_1-1704901466418.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The results should be closer to this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="datagrrl_0-1704901385844.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/126830i6A07BAA567405274/image-size/medium?v=v2&amp;amp;px=400" role="button" title="datagrrl_0-1704901385844.png" alt="datagrrl_0-1704901385844.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Any assistance is appreciated. I have attached a mocked up app.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 15:48:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-for-New-Customers-Each-Month/m-p/2160150#M94092</guid>
      <dc:creator>datagrrl</dc:creator>
      <dc:date>2024-01-10T15:48:09Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for New Customers Each Month</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-for-New-Customers-Each-Month/m-p/2160170#M94094</link>
      <description>&lt;P&gt;If you load your data in order by CustomerID and SalesDate and then use&lt;/P&gt;
&lt;P&gt;AutoNumber(CustomerID&amp;amp;SalesDate) as IDkey&lt;/P&gt;
&lt;P&gt;In your Chart&amp;nbsp;use SalesDate and IDkey, where the expression for the IDkey is for only values that = 1 which will be the 1st time a new CustomerID is present. &lt;BR /&gt;&lt;BR /&gt;This will give you the desired result.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jan 2024 16:51:23 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-for-New-Customers-Each-Month/m-p/2160170#M94094</guid>
      <dc:creator>NellyAcko</dc:creator>
      <dc:date>2024-01-10T16:51:23Z</dc:date>
    </item>
    <item>
      <title>Re: Expression for New Customers Each Month</title>
      <link>https://community.qlik.com/t5/App-Development/Expression-for-New-Customers-Each-Month/m-p/2160813#M94169</link>
      <description>&lt;P&gt;A possible approach given your question...&lt;/P&gt;
&lt;P&gt;To create a bar chart for new customers monthly in Qlik Sense, using the customer's minimum sales date as the month they are considered a new customer, you'll need to employ a combination of Qlik Sense's date functions and aggregation functions. The key here is to identify the first purchase date for each customer and then count the number of new customers for each month.&lt;/P&gt;
&lt;P&gt;Here's a step-by-step approach:&lt;/P&gt;
&lt;OL&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Load Your Data&lt;/STRONG&gt;: Ensure your data is loaded with the &lt;CODE&gt;CustomerID&lt;/CODE&gt; and &lt;CODE&gt;SalesDate&lt;/CODE&gt; fields.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Create a Field for First Purchase Date&lt;/STRONG&gt;: You'll need to create a new field in your data model that represents the first purchase date for each customer.&lt;/P&gt;
&lt;/LI&gt;
&lt;LI&gt;
&lt;P&gt;&lt;STRONG&gt;Aggregate New Customers Monthly&lt;/STRONG&gt;: Use an expression in your bar chart to count the number of unique customers who made their first purchase in each month.&lt;/P&gt;
&lt;/LI&gt;
&lt;/OL&gt;
&lt;P&gt;Here's an example script and expression to guide you:&lt;/P&gt;
&lt;H3&gt;Script to Create a Field for First Purchase Date:&lt;/H3&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="bg-black rounded-md"&gt;
&lt;DIV class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;SPAN&gt;sql&lt;/SPAN&gt;&lt;SPAN class="" data-state="closed"&gt;&lt;BUTTON class="flex gap-1 items-center"&gt;Copy code&lt;/BUTTON&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="p-4 overflow-y-auto"&gt;&lt;CODE class="!whitespace-pre hljs language-sql"&gt;LOAD
    CustomerID,
    SalesDate,
    ...
;

LOAD 
    CustomerID,
    &lt;SPAN class="hljs-built_in"&gt;Min&lt;/SPAN&gt;(SalesDate) &lt;SPAN class="hljs-keyword"&gt;as&lt;/SPAN&gt; FirstPurchaseDate
&lt;SPAN class="hljs-keyword"&gt;FROM&lt;/SPAN&gt; [YourDataSource]
&lt;SPAN class="hljs-keyword"&gt;GROUP&lt;/SPAN&gt; &lt;SPAN class="hljs-keyword"&gt;BY&lt;/SPAN&gt; CustomerID;
&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;In this script, &lt;CODE&gt;Min(SalesDate)&lt;/CODE&gt; calculates the first purchase date for each customer.&lt;/P&gt;
&lt;H3&gt;Expression for Bar Chart:&lt;/H3&gt;
&lt;P&gt;In your bar chart, you'll need an expression to count the number of new customers for each month. The dimension of your bar chart should be the month and year of the &lt;CODE&gt;FirstPurchaseDate&lt;/CODE&gt;, and the expression should count the number of unique &lt;CODE&gt;CustomerID&lt;/CODE&gt;s.&lt;/P&gt;
&lt;P&gt;For the dimension, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="bg-black rounded-md"&gt;
&lt;DIV class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;SPAN&gt;qlik&lt;/SPAN&gt;&lt;SPAN class="" data-state="closed"&gt;&lt;BUTTON class="flex gap-1 items-center"&gt;Copy code&lt;/BUTTON&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="p-4 overflow-y-auto"&gt;&lt;CODE class="!whitespace-pre hljs language-qlik"&gt;Month(FirstPurchaseDate) &amp;amp; '-' &amp;amp; Year(FirstPurchaseDate)
&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;For the expression, use:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;DIV class="bg-black rounded-md"&gt;
&lt;DIV class="flex items-center relative text-gray-200 bg-gray-800 dark:bg-token-surface-primary px-4 py-2 text-xs font-sans justify-between rounded-t-md"&gt;&lt;SPAN&gt;qlik&lt;/SPAN&gt;&lt;SPAN class="" data-state="closed"&gt;&lt;BUTTON class="flex gap-1 items-center"&gt;Copy code&lt;/BUTTON&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV class="p-4 overflow-y-auto"&gt;&lt;CODE class="!whitespace-pre hljs language-qlik"&gt;Count(DISTINCT CustomerID)
&lt;/CODE&gt;&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&lt;LI-WRAPPER&gt;&lt;/LI-WRAPPER&gt;&lt;/P&gt;
&lt;PRE&gt;&amp;nbsp;&lt;/PRE&gt;
&lt;P&gt;This setup will give you a bar chart where each bar represents a month, and the height of the bar represents the number of new customers for that month.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jan 2024 02:56:00 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Expression-for-New-Customers-Each-Month/m-p/2160813#M94169</guid>
      <dc:creator>Scotchy</dc:creator>
      <dc:date>2024-01-12T02:56:00Z</dc:date>
    </item>
  </channel>
</rss>

