<?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 clients with sales in distinct months in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4361631#M173164</link>
    <description>&lt;P&gt;This also didn't work&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":crying_face:"&gt;😢&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Mon, 13 Jan 2025 14:01:49 GMT</pubDate>
    <dc:creator>mayara_alencar</dc:creator>
    <dc:date>2025-01-13T14:01:49Z</dc:date>
    <item>
      <title>Count clients with sales in distinct months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4359327#M173066</link>
      <description>&lt;P&gt;I'm trying to create&amp;nbsp; a measure where I'm counting the distinct clients from a vendor where the client has bought something in the selected month and also in the other two months before. Example: the select month is august and the client has to have sales in august and also in july or june. What i tried to use but is not working:&lt;/P&gt;&lt;P&gt;Active Clients=&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var temp = SUMMARIZECOLUMNS( vw_sales[StartOfMonth],vw_sales[codclient], vw_sales[codvendor],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"actualsales",[.Sales R$],&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;"salesothermonths", [.Compra meses anteriores])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE(distinctcount(vw_sales[codclient]), &amp;nbsp;FILTER(temp, not ISBLANK(sumx(temp, [salesothermonths])) &amp;amp;&amp;amp;sumx(temp, [actualsales])&amp;gt;0))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I also tried and didn't work:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Var salesothermonths = &amp;nbsp;CALCULATE(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; distinctcount(vw_sales[codclient]),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; UNION(&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DATEADD(dimTempo[data], -1, MONTH),&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; DATEADD(dimTempo[data], -2, MONTH)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; )&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var actualsales = CALCULATE(distinctcount(vw_sales[codclient]), DATEADD(dimTempo[data],0,MONTH))&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var ttclientes = distinctcount(vw_sales[codclient])&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RETURN&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;SWITCH(TRUE(),actualsales&amp;gt;0 &amp;amp;&amp;amp; salesothermonths&amp;gt;0,ttclientes)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Help?&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Fri, 10 Jan 2025 19:52:34 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4359327#M173066</guid>
      <dc:creator>mayara_alencar</dc:creator>
      <dc:date>2025-01-10T19:52:34Z</dc:date>
    </item>
    <item>
      <title>Re: Count clients with sales in distinct months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4359531#M173068</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;I tried to create a sample pbix file like below, and please check the below picture and the attached pbix file whether it suits.&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;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Client count: = 
VAR _t = SUMMARIZE ( sales, client[client] ) 
RETURN 
COUNTROWS ( _t )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/dax/window-function-dax?wt.mc_id=DP-MVP-5004989" target="_blank"&gt;WINDOW function (DAX) - DAX | Microsoft Learn&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Client count also in the otehr two months before: =
VAR _t =
    WINDOW (
        -2,
        REL,
        0,
        REL,
        ALL ( 'calendar'[Year-Month], 'calendar'[Year-Month sort] ),
        ORDERBY ( 'calendar'[Year-Month sort], ASC )
    )
RETURN
    CALCULATE ( [Client count:], _t )
&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2025 03:34:37 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4359531#M173068</guid>
      <dc:creator>Jihwan_Kim</dc:creator>
      <dc:date>2025-01-11T03:34:37Z</dc:date>
    </item>
    <item>
      <title>Re: Count clients with sales in distinct months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4359635#M173073</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="911171" data-lia-user-login="mayara_alencar" class="lia-mention lia-mention-user"&gt;mayara_alencar&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can mofiy your dax to achieve the goal :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Active Clients =&lt;BR /&gt;VAR SelectedMonth = SELECTEDVALUE(vw_sales[StartOfMonth]) -- &lt;STRONG&gt;The selected month&lt;/STRONG&gt;&lt;BR /&gt;VAR DateRange =&lt;BR /&gt;DATESINPERIOD(&lt;BR /&gt;vw_sales[StartOfMonth],&lt;BR /&gt;SelectedMonth,&lt;BR /&gt;-2,&lt;BR /&gt;MONTH&lt;BR /&gt;) &lt;STRONG&gt;-- Create a 3-month range including the selected month and 2 prior months&lt;/STRONG&gt;&lt;BR /&gt;RETURN&lt;BR /&gt;CALCULATE(&lt;BR /&gt;DISTINCTCOUNT(vw_sales[codclient]), &lt;STRONG&gt;-- Count distinct clients&lt;/STRONG&gt;&lt;BR /&gt;FILTER(&lt;BR /&gt;vw_sales,&lt;BR /&gt;vw_sales[StartOfMonth] IN DateRange &amp;amp;&amp;amp; &lt;STRONG&gt;-- Check if the StartOfMonth falls within the range&lt;/STRONG&gt;&lt;BR /&gt;vw_sales[Sales R$] &amp;gt; 0 -- Ensure there are sales&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Modify variable and column names as per need.&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;/P&gt;&lt;P&gt;Did I answer your query ? Mark this as solution if this helps, Kudos are appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Sat, 11 Jan 2025 09:06:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4359635#M173073</guid>
      <dc:creator>divyed</dc:creator>
      <dc:date>2025-01-11T09:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: Count clients with sales in distinct months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4361605#M173162</link>
      <description>&lt;P&gt;This one didn't work. It only counted the clients that have sales&amp;gt;0 in the current month. It should count the ones that also have sales in the 2 previous months.&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 13:45:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4361605#M173162</guid>
      <dc:creator>mayara_alencar</dc:creator>
      <dc:date>2025-01-13T13:45:12Z</dc:date>
    </item>
    <item>
      <title>Re: Count clients with sales in distinct months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4361631#M173164</link>
      <description>&lt;P&gt;This also didn't work&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":crying_face:"&gt;😢&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 14:01:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4361631#M173164</guid>
      <dc:creator>mayara_alencar</dc:creator>
      <dc:date>2025-01-13T14:01:49Z</dc:date>
    </item>
    <item>
      <title>Re: Count clients with sales in distinct months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4361648#M173165</link>
      <description>&lt;P&gt;This is an example of what i mean:&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;And this should be the result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's the sample:&lt;/P&gt;&lt;P&gt;&lt;A href="https://docs.google.com/spreadsheets/d/1yGqT_PfDOEyJXwWDAgcuut5OKqUIUcHMrytziVVRrTM/edit?usp=drivesdk" target="_self"&gt;Sample table&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 13 Jan 2025 14:09:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4361648#M173165</guid>
      <dc:creator>mayara_alencar</dc:creator>
      <dc:date>2025-01-13T14:09:05Z</dc:date>
    </item>
    <item>
      <title>Re: Count clients with sales in distinct months</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4373031#M173614</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="911171" data-lia-user-login="mayara_alencar" class="lia-mention lia-mention-user"&gt;mayara_alencar&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Thanks for the reply from&amp;nbsp;divyed&amp;nbsp;and&amp;nbsp;Jihwan_Kim. You can try the following dax to achieve your need.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Active = 
VAR _slicerMonth = SELECTEDVALUE(Slicer[month])
VAR _earlierMonth = _slicerMonth - 2
VAR _month = SELECTEDVALUE('Table 1'[month])
VAR _result = IF(_month&amp;gt;=_earlierMonth &amp;amp;&amp;amp; _month &amp;lt;=_slicerMonth,CALCULATE(COUNTROWS('Table 2'),FILTER('Table 2','Table 2'[Active?] = "Active")))
RETURN
_result

Inactive = 
VAR _slicerMonth = SELECTEDVALUE(Slicer[month])
VAR _earlierMonth = _slicerMonth - 2
VAR _month = SELECTEDVALUE('Table 1'[month])
VAR _result = IF(_month&amp;gt;=_earlierMonth &amp;amp;&amp;amp; _month &amp;lt;=_slicerMonth,CALCULATE(COUNTROWS('Table 2'),FILTER('Table 2','Table 2'[Active?] = "Inactive")))
RETURN
_result&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&lt;SPAN&gt;Best Regards,&lt;BR /&gt;Yang&lt;/SPAN&gt;&lt;SPAN&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;Community Support Team&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="text-align: justify; text-justify: inter-ideograph;"&gt;&amp;nbsp;&lt;/P&gt;
&lt;P style="background: white;"&gt;&lt;SPAN&gt;If there is any post &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;helps&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;, then please consider &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Accept it as the solution&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;to&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;help the other members find it more quickly.&lt;BR /&gt;If I misunderstand your needs or you still have problems on it, please feel free to let us know. &lt;/SPAN&gt;&lt;STRONG&gt;&lt;SPAN&gt;Thanks a lot!&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;
&lt;P style="background: white;"&gt;&lt;U&gt;&lt;SPAN&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-Get-Your-Question-Answered-Quickly%2Fba-p%2F38490&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7C326a6d727194478c197008dbefc04904%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638367381365912356%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=7IzyI2%2FMOAR%2FYCjWYSKCZL2VPmT4PsxuWBjdUdMWKzo%3D&amp;amp;reserved=0" target="_blank"&gt;How to get your questions answered quickly&lt;/A&gt;&lt;/SPAN&gt;&lt;/U&gt;&lt;SPAN&gt;&amp;nbsp;-- &lt;/SPAN&gt;&lt;U&gt;&lt;SPAN&gt;&lt;A href="https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fcommunity.powerbi.com%2Ft5%2FCommunity-Blog%2FHow-to-provide-sample-data-in-the-Power-BI-Forum%2Fba-p%2F963216&amp;amp;data=05%7C01%7Cv-yaningyang%40microsoft.com%7C326a6d727194478c197008dbefc04904%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C638367381365919045%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&amp;amp;sdata=VeafzdwAsrpisD8s261%2FdyOwJ1aCtBXS3bPA6NODOHY%3D&amp;amp;reserved=0" target="_blank"&gt;&amp;nbsp;How to provide sample data in the Power BI Forum&lt;/A&gt;&lt;/SPAN&gt;&lt;/U&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Jan 2025 07:00:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-clients-with-sales-in-distinct-months/m-p/4373031#M173614</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2025-01-21T07:00:42Z</dc:date>
    </item>
  </channel>
</rss>

