This message was deleted.
# ask-questions
w
This message was deleted.
h
Great question. This is definitely a blind spot in the app. Because
timestamp
isn't a required field in the User Dimension definition, we have to use some arbitrary rule making to select one user dimension per user (right now we just use
MAX
). On your end, the best way to handle this would be to define your User Dimension using SQL Template variables where you define your user dimension yourself to get the latest record per user that has a
timestamp < {{startDate}}
so that you can ensure all dimensions are pre-experiment (best for bias).
You could do something like the following:
Copy code
WITH visitor_types AS (
SELECT
  anonymous_id,
  visitor_type,
  ROW_NUMBER() OVER (PARTITION BY anonymous_id ORDER BY timestamp DESC) AS rn
FROM
  dim_table
WHERE
  timestamp > DATE_SUB({{startDate}}, INTERVAL 7 DAY) AND timestamp < {{startDate}}
)

SELECT
  anonymous_id,
  visitor_type
FROM visitor_types
WHERE rn = 1
p
Thank you Luke, I'll try that
140 Views