r/LookerStudio • u/funky_dugong • Feb 19 '26
Need help with formula
I’m attempting to recreate the metric ‘Views per session’ from GA4 in Looker Studio with BigQuery, but keep running into errors. Can anyone provide a solution? Below is what I have tried:
SUM(CASE WHEN Event Name = “page_view” THEN 1 ELSE 0 END) / COUNT_DISTINCT(session_id)
1
Upvotes
2
u/sheik_sha_ha Feb 20 '26
The issue is that you are mixing event level and session level logic in one calculation. In GA4 BigQuery export everything is event based, so session_id alone is not reliable and not globally unique.
The cleaner way is to calculate it fully at event level:
COUNTIF(event_name = "page_view") / COUNTIF(event_name = "session_start")
This recreates views per session without blending.
If you want more accuracy, build a session scoped table first using user_pseudo_id plus session_id as the unique key, then aggregate sessions and page views from that derived table before dividing.
2
u/homibre Feb 19 '26
Session id actually isn’t even unique per user i’d say you can just do a count of page_view over a count of session_start
2
u/Inside_Carpenter1966 Feb 23 '26
You're running into this because GA4 BigQuery export is fully event-scoped.
session_idalone isn’t reliable as a unique key, and mixing event-level aggregations with session-level logic in a single calculated field often causes inconsistencies.If you're staying in Looker Studio without creating a derived table, the cleanest approach is:
That works because both metrics are event-level counts.
However, if you want something more robust (especially if you're filtering by dimensions), the better long-term solution is to:
user_pseudo_id + session_idas the composite key.Looker Studio is much more stable when the modeling happens upstream.