<?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 Subsetting Query in DAX in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2733777#M83799</link>
    <description>&lt;P&gt;Hi,&lt;BR /&gt;I've looked around the internet and aren't able to see a comment on what I'm trying to achieve so I'm hoping someone will be able to to tell me if this is possible in a DAX measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By way of an example, I want to measure how many customers have a monthly subscription for the first 5 months but those same customers don't have a subscription on the 6th month.&lt;/P&gt;&lt;P&gt;The table would be transactional with a record of each month a Customer has been subscribed. Customers being a list ID's and&amp;nbsp;subscriptionMonth would be an integer value with "0" representing the first subscription month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eg.&lt;/P&gt;&lt;P&gt;CustomerID, Subscription Start, Subsciption To ,&amp;nbsp;subscriptionMonth&lt;/P&gt;&lt;P&gt;12345, 1 Jul 2022, 31 July 2022, 0&lt;/P&gt;&lt;P&gt;12345, 1 Jul 2022, 31 Aug 2022, 1&lt;/P&gt;&lt;P&gt;12345, 1 Jul 2022, 30 Sept 2022, 2&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In SQL it would look something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select count (distinct Customers)&lt;/P&gt;&lt;P&gt;from subscriptions&lt;/P&gt;&lt;P&gt;where&amp;nbsp;subscriptionMonth &amp;lt;=5&lt;/P&gt;&lt;P&gt;and Customers NOT in&amp;nbsp;(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; select distinct Customers,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;From subscriptions&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where subscriptionMonth = 6 )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I'd like the measure to create a list of Customers that are in the 0 to 5 months and then pass that Customer list through to the next level of the measure see if those Customers are in the list for the 6th month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to do this dynamically in the front end because I want expand this out and parameterise the 0, 5 and 6 values so the end user could interact with a slider or similar and view the continuance rates for Customers in the 0 to 8 or 10 month range etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help and I hope this makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 30 Aug 2022 01:47:00 GMT</pubDate>
    <dc:creator>AnthonyJ</dc:creator>
    <dc:date>2022-08-30T01:47:00Z</dc:date>
    <item>
      <title>Subsetting Query in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2733777#M83799</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I've looked around the internet and aren't able to see a comment on what I'm trying to achieve so I'm hoping someone will be able to to tell me if this is possible in a DAX measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;By way of an example, I want to measure how many customers have a monthly subscription for the first 5 months but those same customers don't have a subscription on the 6th month.&lt;/P&gt;&lt;P&gt;The table would be transactional with a record of each month a Customer has been subscribed. Customers being a list ID's and&amp;nbsp;subscriptionMonth would be an integer value with "0" representing the first subscription month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Eg.&lt;/P&gt;&lt;P&gt;CustomerID, Subscription Start, Subsciption To ,&amp;nbsp;subscriptionMonth&lt;/P&gt;&lt;P&gt;12345, 1 Jul 2022, 31 July 2022, 0&lt;/P&gt;&lt;P&gt;12345, 1 Jul 2022, 31 Aug 2022, 1&lt;/P&gt;&lt;P&gt;12345, 1 Jul 2022, 30 Sept 2022, 2&lt;/P&gt;&lt;P&gt;etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In SQL it would look something like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;select count (distinct Customers)&lt;/P&gt;&lt;P&gt;from subscriptions&lt;/P&gt;&lt;P&gt;where&amp;nbsp;subscriptionMonth &amp;lt;=5&lt;/P&gt;&lt;P&gt;and Customers NOT in&amp;nbsp;(&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; select distinct Customers,&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;From subscriptions&lt;/P&gt;&lt;P&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;where subscriptionMonth = 6 )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Basically, I'd like the measure to create a list of Customers that are in the 0 to 5 months and then pass that Customer list through to the next level of the measure see if those Customers are in the list for the 6th month.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'd like to do this dynamically in the front end because I want expand this out and parameterise the 0, 5 and 6 values so the end user could interact with a slider or similar and view the continuance rates for Customers in the 0 to 8 or 10 month range etc...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help and I hope this makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 01:47:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2733777#M83799</guid>
      <dc:creator>AnthonyJ</dc:creator>
      <dc:date>2022-08-30T01:47:00Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Query in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2734185#M83818</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="370891" data-lia-user-login="AnthonyJ" class="lia-mention lia-mention-user"&gt;AnthonyJ&lt;/a&gt; , You just need two measure purchases in 5 months not in 6th ,&lt;/P&gt;
&lt;P&gt;if based on rolling&lt;/P&gt;
&lt;P&gt;refer&lt;/P&gt;
&lt;P&gt;Power BI- Customer Purchasing in each of the last 3 months: &lt;A href="https://youtu.be/bGtjoccEA38" target="_blank" rel="noopener"&gt;https://youtu.be/bGtjoccEA38&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;same as lost customer here&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Period over Period Retention :&lt;A href="https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458" target="_blank" rel="noopener"&gt;https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Or use meausre like&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculate(Sum(Table[Value]), filter('Date', month('Date'[Date]) &amp;lt;5 ))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculate(Sum(Table[Value]), filter('Date', month('Date'[Date]) = 6 ))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or use all&lt;/P&gt;
&lt;P&gt;Calculate(Sum(Table[Value]), filter(all('Date'), month('Date'[Date]) &amp;lt;5 ))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Calculate(Sum(Table[Value]), filter(('Date') , month('Date'[Date]) = 6 ))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;based on selected date or today&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;or use all&lt;/P&gt;
&lt;P&gt;first 5 = &lt;BR /&gt;var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;/P&gt;
&lt;P&gt;var _max = eomonth(_max1,(-1*MONTH(_max1)) +5 ) &lt;BR /&gt;var _min = eomonth(_max1,-1*MONTH(_max1))+1 &lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;6th&amp;nbsp; = &lt;BR /&gt;var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())&lt;/P&gt;
&lt;P&gt;var _max = eomonth(_max1,(-1*MONTH(_max1)) +6 ) &lt;BR /&gt;var _min = eomonth(_max1,(-1*MONTH(_max1)) +5 ) +1 &lt;BR /&gt;return&lt;BR /&gt;CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With any set of measure , follow lost customer logic give in blog and video&lt;/P&gt;</description>
      <pubDate>Tue, 30 Aug 2022 06:31:10 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2734185#M83818</guid>
      <dc:creator>amitchandak</dc:creator>
      <dc:date>2022-08-30T06:31:10Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Query in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2739271#M84120</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="148838" data-lia-user-login="amitchandak" class="lia-mention lia-mention-user"&gt;amitchandak&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;Thank you so much for your reply. These will be great tools to have in the tool belt. You did find a hole in my analogy however as our processes allow for Customers to come in and out of the subscriptions so when comparing the 0 to 5 it has to be the same cohort of Customers being queried in the 6th. It is possible in our circumstances (however rare) that the 6th period could be the first month of subscription which would mean a Customer in the numerator that's not in the denominator.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This may be a challenge but I'm interested to know if PowerBI can acheive this. Can PowerBI take a list of Customers found in the 0 to 5 and pass it through as an extra filter condition to the 6th in DAX?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The reason I want to do it in DAX is because I'd like a slider that will allow the variables (0 and 5) to move, allowing the end user to investigate different periods (For example: 0 to 7 and still there in 8th or 5 to 10 and still there in 11). It's because of this dynamic nature I'm trying to avoid pre-processing in PowerQuery.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, Thank you for your help and time.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Anthony&lt;/P&gt;</description>
      <pubDate>Thu, 01 Sep 2022 00:59:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2739271#M84120</guid>
      <dc:creator>AnthonyJ</dc:creator>
      <dc:date>2022-09-01T00:59:12Z</dc:date>
    </item>
    <item>
      <title>Re: Subsetting Query in DAX</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2753968#M85059</link>
      <description>&lt;P&gt;Hi,&lt;BR /&gt;I appreciate your time supplying the blogs on customer retention and the DAX code for measuring the 0-5 and 6 cohorts. This will, no doubt provide a solution to future features to build.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;I've marked you solution as accepted as it seems PowerBI isn't able to dynamically create a list of customers and pass this through as a parameter to determine if those same customers were also in the sixth month or allow a variable slider to dynamically choose the range investigated. eg months 0-7 or 5-9.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 07 Sep 2022 22:58:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Subsetting-Query-in-DAX/m-p/2753968#M85059</guid>
      <dc:creator>AnthonyJ</dc:creator>
      <dc:date>2022-09-07T22:58:38Z</dc:date>
    </item>
  </channel>
</rss>

