Forum Discussion
Counting repeat customers
- 6 years ago
I see what you mean. Tricky this one, but I think I've cracked it.
Give this a try:
1) First measure:
Distinctcount years = CALCULATE(DISTINCTCOUNT('Customer data'[year]); ALLEXCEPT('Customer data'; 'Customer data'[Customer]; 'Customer data'[Country];'Customer data'[part number]))2) Final Measure to deliver repeating customers:
Repeating Customers = CALCULATE(DISTINCTCOUNT('Customer data'[Customer]); FILTER(ALL('Customer data'[Customer]); [Distinctcount years]>1)) +0
Try this:
(In my examples, I've named your sample table 'Customer Data'):
1) Calculate number of years per customer:
Distinctcount years = CALCULATE(DISTINCTCOUNT('Customer data'[year]);
ALLEXCEPT('Customer data'; 'Customer data'[Customer]))
2) Count the number of customers who have bought in at least 2 years:
Repeating Customers = CALCULATE(
DISTINCTCOUNT('Customer data'[Customer]);
FILTER('Customer data';
[Distinctcount years]>1)) + 0
(NB the + 0 at the end is to avoid seeing "BLANK()" as a result)
See if that works for you.
- CL77776 years agoHelper III
Thanks for your repsonse. This is not exactly working because it calculates the number of repeat customers, but not if I were to filter by product for example. The first measure you wrote calculates the number of years that each customer purchased something but it would need to count the number of years that each customer purchased a particular part. When I filter by part in the visual, it doesnt work.
- PaulDBrown6 years agoCommunity Champion
I see what you mean. Tricky this one, but I think I've cracked it.
Give this a try:
1) First measure:
Distinctcount years = CALCULATE(DISTINCTCOUNT('Customer data'[year]); ALLEXCEPT('Customer data'; 'Customer data'[Customer]; 'Customer data'[Country];'Customer data'[part number]))2) Final Measure to deliver repeating customers:
Repeating Customers = CALCULATE(DISTINCTCOUNT('Customer data'[Customer]); FILTER(ALL('Customer data'[Customer]); [Distinctcount years]>1)) +0