Forum Discussion
Subsetting Query in DAX
- 3 years ago
AnthonyJ , You just need two measure purchases in 5 months not in 6th ,
if based on rolling
refer
Power BI- Customer Purchasing in each of the last 3 months: https://youtu.be/bGtjoccEA38
same as lost customer here
Period over Period Retention :https://community.powerbi.com/t5/Community-Blog/Customer-Retention-Part-2-Period-over-Period-Retention/ba-p/1377458
Or use meausre like
Calculate(Sum(Table[Value]), filter('Date', month('Date'[Date]) <5 ))
Calculate(Sum(Table[Value]), filter('Date', month('Date'[Date]) = 6 ))
or use all
Calculate(Sum(Table[Value]), filter(all('Date'), month('Date'[Date]) <5 ))
Calculate(Sum(Table[Value]), filter(('Date') , month('Date'[Date]) = 6 ))
based on selected date or today
or use all
first 5 =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())var _max = eomonth(_max1,(-1*MONTH(_max1)) +5 )
var _min = eomonth(_max1,-1*MONTH(_max1))+1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))6th =
var _max1 = if(isfiltered('Date'),MAX( 'Date'[Date]) , today())var _max = eomonth(_max1,(-1*MONTH(_max1)) +6 )
var _min = eomonth(_max1,(-1*MONTH(_max1)) +5 ) +1
return
CALCULATE([net] ,DATESBETWEEN('Date'[Date],_min,_max))With any set of measure , follow lost customer logic give in blog and video
Hi amitchandak,
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.
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?
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.
Again, Thank you for your help and time.
Regards
Anthony