Skip to content
Advertisement

How to get cumulative total users but ignoring the users who already appear in previous day? using bigquery

So I want to calculate cumulative users per day but if the users exist is previous days they will not counted.

on daily basis we can get

if we simply calculate cumulative we can get 2,4,6,8 for each day the goal is to get the table like this

im using this query to get the result, since the data is really2 huge. the query takes forever to complete.

and yes the calculation should be on reset when the month is changing.

and btw I’m using google bigquery

Advertisement

Answer

Number each user’s appearance by order of date. Count only the ones seen for the first time:

https://dbfiddle.uk/?rdbms=postgres_14&fiddle=dc426d79a7786fc8a5b25a22f0755e27

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement