Counting active customers

I have a dataset of transactions with a customer id and timestamp for each. For a client to be classified as “active” they need to have done at least 10 transactions in the last 30 days.

I want to show:

  1. the current COUNT of active customers
  2. how the count of active customers has varied over time

I seem to be going round in circles with windowSum as I don’t want to show all the customer ids on the visualisation I just want the count of them. I must be missing something, as an analysis as simple as this shouldn’t be that hard, surely?

Any guidance would be most welcome, thanks!

Hi @freshaspect -

You can use LAC-W and dateDiff functions for this.

Step 1 - Create a calculated field that counts the number of transactions within 30 days

// use LAC-A to retrive rows (transactions) in last 30 days, grouped by user

countOver(ifelse(dateDiff(dt,now()) >= 30,1,0),[{user_id}], PRE_AGG)

Step 2 - Create a calculated field that only shows user_id if c_transactions_last_30_cnt is over 10.



Many thanks! I’ll give this a go and report back - really appreciate the detailed response.

Don’t understand how part 2 of this can work if the count is including now(). For example, if looking at the active number user account for 25 June 2022, it should be looking at who did at least 10 transactions between 24th May 2022 and 25th June 2022.

Maybe I am missing something but doesn’t this need to be using a moving time window?

In the end I had to move all the logic down to the SQL layer to get this to work which was pretty frustrating. Maybe there’s a way to get this to work - if I get a chance, I will revisit. Thanks again for your suggestion though.

@freshaspect -

Sorry about the delay. I took your definition of active customers as 30 days from current date. Where you need it as a rolling/window from the date of the transaction.

I wasn’t able to find another workaround and was going to suggest moving to the ETL layer, which I see you did.

I’ll flag this as a feature request and continue to explore if an acceptable workaround exists.

1 Like