Forum Discussion
Active and Inactive customers
Hi all,
I need active customers count and inactive customers count Active customers are within the 6 months and Inactive customers are +6months
table A
id date
1 1/1/2018
1 1/1/2019
2 1/2/2018
2 1/12/2018
3 1/1/2016
3 1/1/2017
4 1/1/2015
4 1/8/2015
1 1/8/2017
when I filter the data in slicer from 1/1/2018 to 1/1/2019, here Active customers id is 1 and count is 1 and Inactive customers are 2 and count is 1
here I try the formula but getting error
CALCULATE(
DISTINCTCOUNT( TableA[ID] ) ),
DATESINPERIOD( TableA[DATE].[Date], MAX( TableA[DATE].[Date] ), -6, MONTH )
)A date column containing duplicate dates as specified in the call to function 'DATESINPERIOD'.
8 Replies
- amitchandakSuper User
First of all .date is only need when you have a timestamp. Second use a date table. 3 formulas, I am giving. Third one should work
//1 CALCULATE( DISTINCTCOUNT( TableA[ID] ) ), DATESINPERIOD( TableA[DATE], MAX( TableA[DATE] ), -6, MONTH ) ) //2 CALCULATE( DISTINCTCOUNT( TableA[ID] ) ), DATESINPERIOD( DATE[DATE], MAX( DATE[DATE] ), -6, MONTH ) ) //3 sumx(summarize(calculatetable(TableA,DATESINPERIOD( DATE[DATE], MAX( DATE[DATE] ), -6, MONTH )), TableA[ID] , "_active",distinctcount(TableA[ID])),_active)To get the best of the time intelligence function. Make sure you have a date calendar and it has been marked as the date in model view. Also, join it with the date column of your fact/s.
Refer
https://radacad.com/creating-calendar-table-in-power-bi-using-dax-functions
https://www.archerpoint.com/blog/Posts/creating-date-table-power-bi
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges
Connect on Linkedin- manideep547Helper III
amitchandak for 3 formula getting error parameter is not the correct type.cannot find the name _active
- amitchandakSuper User
missed [ ]
sumx(summarize(calculatetable(TableA,DATESINPERIOD( DATE[DATE], MAX( DATE[DATE] ), -6, MONTH )), TableA[ID] , "_active",distinctcount(TableA[ID])),[_active])