Forum

Distinct customer c...
 
Notifications
Clear all

Distinct customer count with condition

5 Posts
2 Users
0 Reactions
57 Views
(@lindac)
Posts: 32
Trusted Member
Topic starter
 

Hi,

I wish to do a simple distinct count of lapsed customers. We define lapsed customers as those who have not made a purchase in the last 3 years, so I have created an explicit measure Lost Days Limit = 1095 + 1.

How do I write the formula to count distinct [CustomerKey] or customers whose [LastTransactionDate] >= [LostDaysLimit]? Thank you.

 
Posted : 12/04/2019 4:17 am
(@mynda)
Posts: 4761
Member Admin
 

Hi Linda,

Try

=CALCULATE(

DISTINCTCOUNT( FactTable[CustomerKey] ) ,

[LastTransactionDate] >= [LostDaysLimit] )

Mynda

 
Posted : 12/04/2019 4:56 am
(@lindac)
Posts: 32
Trusted Member
Topic starter
 

Hi Mynda,

Thanks. The syntax for [LostDaysLimit] wasn't correct so I ended up typing in 1096 days into the measure.

I then tried the formula you suggested in a couple of ways. One, where the data type of [LastTransactionDate] was a date. Two, where I transformed [LastTransactionDate] into a duration in days. However, both of them returned the full customer count instead of the lapsed customer count.

What else could I try? Thanks

 
Posted : 12/04/2019 11:23 pm
(@mynda)
Posts: 4761
Member Admin
 

Hi Linda,

My suggested formula was just that, a suggestion based on what you already knew, but in hindsight I should have noticed that you were trying to compare a date to a number i.e. last transaction date >= number of lost days, as that doesn't make sense.

Your lost days limit formula needs to return a date. e.g.

=CALCULATE(

DISTINCTCOUNT( FactTable[CustomerKey] ) ,

[LastTransactionDate] <= DATEADD(DateTable[DateColumn], -1096, days) )

This requires a date in the PivotTable row, column or filters for the DATEADD function to know what date it's shifting -1096 days from.

Mynda

 
Posted : 13/04/2019 12:37 am
(@lindac)
Posts: 32
Trusted Member
Topic starter
 

Thank you Mynda. I need to swot up on the time intelligence lessons to get a better handle on this!

 
Posted : 13/04/2019 1:42 am
Share: