<?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: Counting New Customers based on conditions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4008695#M157387</link>
    <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;The measure works great, thank you! I stumbled across another issue with it. If the user selects the year from the slicer on the page , the count is not accurate anymore? Do you know if there is a way to fix this?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Your help is very much appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 25 Jun 2024 08:35:48 GMT</pubDate>
    <dc:creator>Zosy</dc:creator>
    <dc:date>2024-06-25T08:35:48Z</dc:date>
    <item>
      <title>Counting New Customers based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4007255#M156946</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am trying to find all the new customers that match the below criteria:&lt;BR /&gt;- they haven't bought anything in the past 5 years&lt;BR /&gt;- they never bought merchandise on a pallet&lt;BR /&gt;- they never bought merchandise in a red box&lt;/P&gt;&lt;P&gt;I have created the measure below but it's not returning the correct counts.&lt;BR /&gt;&lt;BR /&gt;In 2017 there were 3 customers who purchased products, but only 1 is considered a new customer because the other two purchased a red box and a pallet.&lt;BR /&gt;In 2018 there were 0 new customers; same 2019-2022.&lt;BR /&gt;In 2023 there is 1 new customer.&lt;BR /&gt;&lt;BR /&gt;I have uploaded the file in dropbox. Hope this helps&lt;BR /&gt;&lt;BR /&gt;&lt;A title="New Customers" href="https://www.dropbox.com/scl/fi/j94hiw7sey5g8df93dq35/New-customers.pbix?rlkey=9zu3ubgw1xg2tpistyi889u2g&amp;amp;st=ygn0kz3k&amp;amp;dl=0" target="_self"&gt;New Customers.pbix&lt;/A&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;All new Customers = 
var customer = SELECTEDVALUE('Invoices'[customer name])

var LastPurchaseDate = SELECTEDVALUE('Invoices'[New Invoice Date])
            
var PreviousPurchaseDate = CALCULATE(
                MAX ( 'Date'[Date]  ), 
                FILTER(ALL('Invoices'), 'Invoices'[New Invoice Date] &amp;lt; LastPurchaseDate &amp;amp;&amp;amp; 'Invoices'[customer name] = customer))

var PreviousPurchase = IF(ISBLANK(PreviousPurchaseDate),LastPurchaseDate,PreviousPurchaseDate)

var N = CALCULATE(DISTINCTCOUNTNOBLANK('Invoices'[customer name]),
    FILTER (
        'Invoices',
        DATEDIFF('Invoices'[New invoice Date] ,LastPurchaseDate,YEAR)&amp;gt;5 &amp;amp;&amp;amp; 'Invoices'[Pallet] &amp;lt;&amp;gt;"Pallet" || 'Invoices'[Box Colour] &amp;lt;&amp;gt; "Red")

    )

VAR R = DISTINCTCOUNTNOBLANK('Invoices'[customer name])-N

return
N&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Mon, 24 Jun 2024 15:37:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4007255#M156946</guid>
      <dc:creator>Zosy</dc:creator>
      <dc:date>2024-06-24T15:37:25Z</dc:date>
    </item>
    <item>
      <title>Re: Counting New Customers based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4007484#M156961</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please check the below picture and the attached pbix file.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;All new Customers V2: =
VAR _customerlistcurrentyear =
    VALUES ( Invoices[customer name] )
VAR _customerlistpreviousfiveyears =
    CALCULATETABLE (
        VALUES ( Invoices[customer name] ),
        WINDOW ( -5, REL, -1, REL, ALL ( 'Date'[Year] ), ORDERBY ( 'Date'[Year], ASC ) )
    )
VAR _condition =
    CALCULATETABLE (
        VALUES ( Invoices[customer name] ),
        'Invoices'[Pallet] = "Pallet"
            || 'Invoices'[Box Colour] = "Red"
    )
VAR _newcustomerlist =
    EXCEPT ( _customerlistcurrentyear, _customerlistpreviousfiveyears )
VAR _withoutcondition =
    EXCEPT ( _newcustomerlist, _condition )
RETURN
    COUNTROWS ( _withoutcondition )
&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 24 Jun 2024 17:35:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4007484#M156961</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-06-24T17:35:35Z</dc:date>
    </item>
    <item>
      <title>Re: Counting New Customers based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4008695#M157387</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt; ,&lt;BR /&gt;&lt;BR /&gt;The measure works great, thank you! I stumbled across another issue with it. If the user selects the year from the slicer on the page , the count is not accurate anymore? Do you know if there is a way to fix this?&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;Your help is very much appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 25 Jun 2024 08:35:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4008695#M157387</guid>
      <dc:creator>Zosy</dc:creator>
      <dc:date>2024-06-25T08:35:48Z</dc:date>
    </item>
    <item>
      <title>Re: Counting New Customers based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4010223#M157789</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please try something like below.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;All new Customers V2: =
VAR _customerlistcurrentyear =
    VALUES ( Invoices[customer name] )
VAR _customerlistpreviousfiveyears =
    CALCULATETABLE (
        VALUES ( Invoices[customer name] ),
        WINDOW ( -5, REL, -1, REL, ALL ( 'Date'[Year] ), ORDERBY ( 'Date'[Year], ASC ) ),
        REMOVEFILTERS ( 'Date' )
    )
VAR _condition =
    CALCULATETABLE (
        VALUES ( Invoices[customer name] ),
        WINDOW ( -5, REL, 0, REL, ALL ( 'Date'[Year] ), ORDERBY ( 'Date'[Year], ASC ) ),
        REMOVEFILTERS ( 'Date' ),
        'Invoices'[Pallet] = "Pallet"
            || 'Invoices'[Box Colour] = "Red"
    )
VAR _newcustomerlist =
    EXCEPT ( _customerlistcurrentyear, _customerlistpreviousfiveyears )
VAR _withoutcondition =
    EXCEPT ( _newcustomerlist, _condition )
RETURN
    COUNTROWS ( _withoutcondition )
&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 26 Jun 2024 02:56:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4010223#M157789</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2024-06-26T02:56:59Z</dc:date>
    </item>
    <item>
      <title>Re: Counting New Customers based on conditions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4010926#M157856</link>
      <description>&lt;P&gt;Thank you &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="291628" data-lia-user-login="Jihwan_Kim" class="lia-mention lia-mention-user"&gt;Jihwan_Kim&lt;/a&gt; ! Your help is very much appreciated!&lt;/P&gt;</description>
      <pubDate>Wed, 26 Jun 2024 09:36:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Counting-New-Customers-based-on-conditions/m-p/4010926#M157856</guid>
      <dc:creator>Zosy</dc:creator>
      <dc:date>2024-06-26T09:36:31Z</dc:date>
    </item>
  </channel>
</rss>

