<?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: DAX code to calculate number of customerships in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3068699#M106375</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332147" data-lia-user-login="v-zhangti" class="lia-mention lia-mention-user"&gt;v-zhangti&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is an example of data below. Do you also want it as an Excel file?&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the best case, I expect to make a line chart which shows the number of customers and date is in x-axis (for example: 1.2.2020 we had 100 customers, 1.3.2020 we had 110 customers(/customerships)). Then I could also filter for example 20-29 year old women who lived in Paris (women who were 20-29y in that date in a-axis and lived in Paris then) and see how much customers we had in different dates using just that filtering. Is that somehow possible to do? I guess that my code not work now because there are not relation between customership and address. (Sorry I change table names a little.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time&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;</description>
    <pubDate>Wed, 08 Feb 2023 10:49:13 GMT</pubDate>
    <dc:creator>Julkor</dc:creator>
    <dc:date>2023-02-08T10:49:13Z</dc:date>
    <item>
      <title>DAX code to calculate number of customerships</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3066091#M106167</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have three different tables and I try to count number of customers. I would also want filter customers with sex, age and addresses. I would want to see what kind of people have been customers at some year, month etc. Somehow it doesn't work...&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have these kinds of tables:&amp;nbsp;&lt;/P&gt;&lt;P&gt;Columns in table Customer: Unique customer key, birthday, sex&lt;/P&gt;&lt;P&gt;Columns in table Customership: Customer key, Start date of customership, End date of customership&lt;/P&gt;&lt;P&gt;Columns in table Address: Customer key, address information, Start date of address, End date of address&lt;/P&gt;&lt;P&gt;+ Two tables Agegroups and All_postcodes which includes list of ages and postcodes.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Tables Customer-Customership has relation with Customer key (1-*) and also tables Customer-Address (1-*). When I calculate number of customerships with code below, DAX works but filter Address not work. If I change to COUNT(Customership[Id])-calculation to Customer[Id], it doesn't work at all. What can I do with the code?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My code now:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Number of customership = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;EndDatePerVisual&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Calendar&lt;/SPAN&gt;&lt;SPAN&gt;[Date]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;RESULT&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;count&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Customership&lt;/SPAN&gt;&lt;SPAN&gt;[Id]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;REMOVEFILTERS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Calendar&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;Customership&lt;/SPAN&gt;&lt;SPAN&gt;[Customership_Startdate]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;EndDatePerVisual&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Customership&lt;/SPAN&gt;&lt;SPAN&gt;[Customership_Enddate]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt;= &lt;/SPAN&gt;&lt;SPAN&gt;EndDatePerVisual&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;DATEDIFF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Customer&lt;/SPAN&gt;&lt;SPAN&gt;[Birthday]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;EndDatePerVisual&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;YEAR&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;IN&lt;/SPAN&gt; &lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;Agegroups&lt;/SPAN&gt;&lt;SPAN&gt;[Age]&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Address[Address_Startdate] &amp;lt;= EndDatePerVisual,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Address[Address_Enddate] &amp;gt; EndDatePerVisual,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; Address[Postcode] &lt;/SPAN&gt;&lt;SPAN&gt;IN&lt;/SPAN&gt; &lt;SPAN&gt;VALUES&lt;/SPAN&gt;&lt;SPAN&gt;(All_postcodes[Postcode])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt; &lt;SPAN&gt;RESULT&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thank you in advance&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 07 Feb 2023 11:46:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3066091#M106167</guid>
      <dc:creator>Julkor</dc:creator>
      <dc:date>2023-02-07T11:46:31Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code to calculate number of customerships</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3067676#M106285</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="472165" data-lia-user-login="Julkor" class="lia-mention lia-mention-user"&gt;Julkor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Can you provide &lt;/SPAN&gt;&lt;SPAN&gt;s&lt;/SPAN&gt;&lt;SPAN&gt;ample data for testing? Sensitive information can be removed in advance. What kind of expected results do you expect? You can also show it with pictures or Excel. I look forward to your response.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 08 Feb 2023 03:09:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3067676#M106285</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2023-02-08T03:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code to calculate number of customerships</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3068699#M106375</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332147" data-lia-user-login="v-zhangti" class="lia-mention lia-mention-user"&gt;v-zhangti&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is an example of data below. Do you also want it as an Excel file?&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the best case, I expect to make a line chart which shows the number of customers and date is in x-axis (for example: 1.2.2020 we had 100 customers, 1.3.2020 we had 110 customers(/customerships)). Then I could also filter for example 20-29 year old women who lived in Paris (women who were 20-29y in that date in a-axis and lived in Paris then) and see how much customers we had in different dates using just that filtering. Is that somehow possible to do? I guess that my code not work now because there are not relation between customership and address. (Sorry I change table names a little.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your time&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;</description>
      <pubDate>Wed, 08 Feb 2023 10:49:13 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3068699#M106375</guid>
      <dc:creator>Julkor</dc:creator>
      <dc:date>2023-02-08T10:49:13Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code to calculate number of customerships</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3092781#M108400</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="332147" data-lia-user-login="v-zhangti" class="lia-mention lia-mention-user"&gt;v-zhangti&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Was the data I sent helpful?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 22 Feb 2023 11:48:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3092781#M108400</guid>
      <dc:creator>Julkor</dc:creator>
      <dc:date>2023-02-22T11:48:01Z</dc:date>
    </item>
    <item>
      <title>Re: DAX code to calculate number of customerships</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3094826#M108534</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="472165" data-lia-user-login="Julkor" class="lia-mention lia-mention-user"&gt;Julkor&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You can try the following methods&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Number of customership = 
VAR EndDatePerVisual = MAX(Calendar[Date])
VAR RESULT =
CALCULATE( DISTINCTCOUNT(Customership[Id]),FILTER(ALL(Customership),
    Customership[Customership_Startdate] &amp;lt;= EndDatePerVisual
    &amp;amp;&amp;amp;Customership[Customership_Enddate] &amp;gt;= EndDatePerVisual),
    FILTER(ALL('Address start and end'),'Address start and end'[Address_startdate]&amp;lt;= EndDatePerVisual
    &amp;amp;&amp;amp;'Address start and end'[Address_enddate] &amp;gt; EndDatePerVisual
    &amp;amp;&amp;amp;'Address start and end'[Postalcode] IN VALUES('Address'[Postalcode])))
RETURN 
RESULT&lt;/LI-CODE&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;Is this the result you expect?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Community Support Team _Charlotte&lt;/P&gt;
&lt;P&gt;If this post&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Thu, 23 Feb 2023 08:10:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-code-to-calculate-number-of-customerships/m-p/3094826#M108534</guid>
      <dc:creator>v-zhangti</dc:creator>
      <dc:date>2023-02-23T08:10:03Z</dc:date>
    </item>
  </channel>
</rss>

