Google Data Studio date aggregation - average number of daily users over time

21.1k views Asked by At

This should be simple so I think I am missing it. I have a simple line chart that shows Users per day over 28 days (X axis is date, Y axis is number of users). I am using hard-coded 28 days here just to get it to work.

I want to add a scorecard for average daily users over the 28 day time frame. I tried to use a calculated field AVG(Users) but this shows an error for re-aggregating an aggregated value. Then I tried Users/28, but the result oddly is the value of Users for today. The division seems to be completely ignored.

What is the best way to show average number of daily users over a time frame? Average daily users over 10 days, 20 day, etc.

2

There are 2 answers

0
ToddB On BEST ANSWER

I have been able to do this in an extremely crude and ugly manner using Google Sheets as a means to do the calculation and serve as a data source for Data studio.

This may be useful for other people trying to do the same thing. This assumes you know how to work with GA data in Sheets and are starting with a Report Configuration. There must be a better way.

Example for Average Number of Daily Users over the last 7 days:

  1. Edit the Report Configuration fields:

    • Report Name: create one report per day, in this case 7 reports. Name them (for example) Users-1 through Users-7. These are your Row 2 values. You'll have 7 columns, with the first report name in column B.
    • Start Date and End Date: use TODAY()-X where X is the number of days previous to define the start and end dates for each report. Each report will contain the user count for one day. Report Users-1 will use TODAY()-1 for start and end, etc.
    • Metrics: enter the metrics e.g. ga:users and ga:new users
  2. Create the reports

    • Use 'Run reports' to have the result sheets created and populated.
  3. Create a sheet for an interim data set you will use as the basis for the average calculation. The first column is date, the remaining columns are for the metrics, in this case Users and New Users.

  4. Populate the interim data set with the dates and values. You will reference the Report Configuration to get the dates, and you will pull the metrics from each of the individual reports. At this stage you have a sheet with date in first columns and values in subsequent columns with a row for each day's values. Be sure to use a header.

  5. Finally, create a sheet that averages the values in the interim data set. This sheet will have a column for each metric, with one value per column. The one value is calculated from the series in the interim data set, for example =AVG(interim_sheet_reference:range) or any other calculation you'd like to do.

  6. At last, you can use Data Studio to connect to this data source and use the values. For counts of users such as this example, you would use Sum as the aggregation field type when you are creating the data source.

It's super ugly but it works.

4
yiah On

Try to create a new metric that counts the dates eg

Count of Date = COUNT(Date) or Count of Date = COUNT_DISTINCT(Date) in case you have duplicated dates

Then create another metric for average users

Users AVG = (Users / Count of Date)

The average depends on the timeframe you have selected. If you are selecting the last 28 days the average is for those 28 days (dates), if you filter 20 days the average is for those 20 days etc.

Hope that helps.