Hi team,
I am working on a dashboard where I have a metric ‘Repeat visitors’ which follows the below conditions:
- If a vistor which has made a visit within our selected time range (suppose Jan-Feb 2024) AND
- If in a rolling 90 day period before the selected range (Oct-Dec 2023), the visitor has done the following:
- Made latest 2 visits to Page P of the website OR
- Made latest 3 visits to Page L of the website AND looked at at least 2 products
If 1 AND (2.1 OR 2.2) are satisfied then count the visitor as a repeat visitor otherwise not.
I know that we would need to utilize combinations of if else & distinct count over functions, however I am running into the Mismatched aggregation error. Additionally, the dataset I am working is 40M rows and is expected to grow over time. Using multiple count overs would massively increase the load time.
My current calculated fields:
date_filter_rolling90= ifelse({request_date} >= addDateTime(-90,'DD',{date_filter_start_date}) AND {request_date} <= addDateTime(-90,'DD',{date_filter_end_date}),1,0)
condition1: coalesce(distinct_countIf({visitor_id},{date_filter}=1),0)
condition 2.1:
coalesce(sumIf({number_of_visits},{date_filter_rolling90}=1 AND {page}='P'),0)
condition 2.2:
coalesce(sumIf({number_of_visits},{date_filter_rolling90}=1 AND {page}='L'),0)
coalesce(distinct_countIf({product_id},{date_filter_rolling90}=1),0)
Final condition is basically distinct count of visitor_id where condition1 is true AND either condition 2.1 or 2.2 is true. However, I am unable to put it together in the correct format. I wanted help in figuring out how (or if it is even feasible) to implement this in Quicksight?