Retention rate calculation

Hi all,
I want to calculate the retention rate of users using a feature of an app. This is my formula:
Retention rate = The users who used the feature last month also used the feature this month/ The users who used the feature last month


=> My calculated field:
distinct_countIf({pub_login_name}, truncDate(‘MM’, {event_date}) = truncDate(‘MM’, ${Datefrom}) /

distinct_countIf({pub_login_name}, truncDate(‘MM’, {event_date}) = truncDate(‘MM’, {last month}))

My calculation above only includes the users used the feature this month, it isn’t ‘‘The users who used the feature last month also used the feature this month’’
Thanks a lot

1 Like

Hello @thecuon119, the way you have it set up currently, only checks if the user was active this month in the numerator. We can try setting up some calculated fields

User logins during last month = ifelse({Date Month} = truncDate('MM', addDateTime(-1, 'MM', now())), {pub_login_name}, NULL)

Lag User logins during last month = lag({User logins during last month}, [{Date Month} ASC], 1, [{pub_login_name}])

Users in Both Months = ifelse(isNotNull({Lag User logins during last month}), 1, 0)

Now you should be able to calculate the numerator of the function and get the percent value you are looking for! I’ll mark this as the solution, let me know if you have any questions.

Hello @thecuon119, since we have not heard back from you, I will mark my above response as the solution. If you have any further questions on this, please let me know and I will guide you further. Thank you!

Hi Dylan,
Thank you for the solution. When I try to aggregate the values to get the %, it throws an error saying mismatched aggregation. Any idea how to get the aggregations on this? I replicated this for Week instead of month.