Google Datastudio: Categorize new and returning user id based on their first appearance date - google-data-studio

I want to categorise users to the new and returning users based on their first appearance date in Data Studio, so if I select the date range of June 1, 2019, to June 30, 2019, every user with first appearance date is on that period is categorised as a new and every users before that period categorised as the returning users.
The data looks like this:
user_id
Firstcontact
9020784665
21/05/19
80302116604
21/05/19
34032004987
02/06/19
85963021828
03/06/19
42703694037
04/06/19
7985228940
05/06/19
39174203617
06/06/19
62014629759
06/06/19
71599733666
06/06/19
3617458365
06/06/19
I was considering to use the CASE function but nothing seemed to work.
I expect the output of new users based on selected date in Data Studio

This is something you'll need to create a segment for in Google Analytics to use in Data Studio

Related

Google Studio - How to change the display of dates in line chart?

I am using Google Data Studio and have a date field that comes in as "2022-05-23".
But in the charts themselves they always get displayed as May 23, 2022.
How does one tell google to stick to something like "2022-05-23" or does google insist on spelling out the Month to avoid any confusion?
You can create a calculated field that format the date column as string, using the function FORMAT_DATETIME:
FORMAT_DATETIME("%Y-%m-%d", my_date_column)

Counting values in between two dates in Quicksight

I have a dataset in Quicksight that looks something like this;
I am trying to create a report of daily/weekly/monthly active users. For example, if the date/week/month is in the range of user's first_login & last_login, it should count that user. E.g. the report of Date: 15th March, should show all 3 users as per this dateset.
The report is in the form of Pivot table as below:
Currently, I am counting the distinct Client_ID for Last_login activity. But it keeps decreasing because the Dataset only saves/updates the latest last_login of the user.
Is there any way to modify the formula in a way to count users, who's first and last login fall within the date range?

Google Data studio -Default filter on last month when data is at month level

I have a report with one data source in Google Data Studio. The data is at month level inside the BigQuery table YYYYMM (for example 202001). I have a filter that is set on the year-month dimension which works ok but I would like to add a default value which changes to last month(max(year_month)) available in the table.
Is this possible? I only found the option to hard-code the default selection but this can't be updated dynamically
as in this screen shot
Jaishree's suggestion
You can create an another field/column as same year-month and always keep the latest year-month value as "latest month" or any name you want. You can use logic like
when existing_column = max(year_month) then "latest month" else existing_column
Something like this
existing_column new_column
022020 latest month
012020 012020
122019 122019
112019 122019
You can pass this "latest month" value in the default selection option this option which is just below the dimension. But each time you upload new data you have to update this field like change the table suppose for next month you table should be like
existing_column new_column
032020 latest month
022020 022020
012020 012020
122019 122019
112019 122019
You can make auto update by scheduling queries as well in big query from where you are loading data to Google data studio.
It can be achieved by setting the Date Range (at the chart, report level, Date Range Control, etc) to Last Month.
First, a YYYYMMDD Date field needs to be created at the Data Source. This can be done using the CONCAT function to add a Day (the 15th is used in the formula) and then using the TODATE function (although in this case the TODATE function is not required, however, adding it as best practice):
TODATE(CONCAT(Date, "15"), "%Y%m%d", "%Y%m%d" )
Adding a link to post on the Google Forums (Nimantha; 10 Feb 2020) which also has a GIF to demonstrate the process above as well as adding the Date field at the Report Level.
You can do it by creating a new field where rows that belong to the current year-month are labeled as 'Current Month' while the others could use your preferred formatting (I'm using "%Y%m - %B %Y" as it allows me to sort report dates in a drop down list).
To do so, you need your date column and CURRENT_DATE() in the same format with the help of FORMAT_DATETIME(). Then, you can use CASE WHEN logic as follows:
CASE
WHEN FORMAT_DATETIME("%Y%m", MyDateColumn) != FORMAT_DATETIME("%Y%m", CURRENT_DATE())
THEN FORMAT_DATETIME("%Y%m - %B %Y", MyDateColumn)
ELSE 'Current Month'
END
Finally, you could use a drop down list control with the new field and use 'Current Month' as the default selection. The main advantage is that the code above will be evaluated every time data is refreshed so no extra automations needed.
Hope it works for you.

How can I calculate between two dates per User Pseudo ID for specific events?

I linked Firebase to BigQuery and start using Google Data Studio to create a table to list users by "User Pseudo ID".
My goal is to calculate the difference between two dates, the date of first_open and the date of app_remove to come up with an average retention time.
How can I write the right query in Data Studio?
It can be achieved using the three step process below:
1) HH:MM:SS
The Calculated Field below uses the DATETIME_DIFF function to find the difference between app_remove and first_open, and displays the difference in SECOND (for future reference, set the third input DATETIME_DIFF as required, for example, to view the difference in days, set the input to DAY):
DATETIME_DIFF(app_remove, first_open, SECOND)
2) Type (HH:MM:SS)
Number > Duration (Sec.)
3) Aggregation (HH:MM:SS)
AVG
Google Data Studio Report and a GIF to elaborate:
DATE_DIFF may be what you are looking for.
That is if first_open and app_remove are date fields or date expressions

Search between two dates with ISO8601 format

Using angularjs, dynamodb as DB here.
I have a form where user saves some data. I save my "CreateOn" date in my dynamo db as:
DateTime.UtcNow.ToString("o");
//This saves date in DB as:2018-08-21T12:58:08.7823906Z
Storing like this because dynamo db requires dates (string) to stored in ISO8601 format if you want to use between operator to search for date range.
Now I have a search filters on my page which is basically an angular calendar. When the user selects the date in the calendar( start and end date) I want to get the data back based on the selected date. Here I am using moment to pass the calendar selected date to my api call as:
moment(createdOn).toISOString()
Eg: If they select the Today's date in the calendar I pass the selected date
(Tue Aug 21 2018 00:00:00 GMT-0400 (Eastern Daylight Time)) to the above function
The result of passing this date to moment(createdOn).toISOString() is
2018-08-21T04:00:00.000Z
The search condition at dynamo db is:
conditions.Add(new ScanCondition("CreatedOn", ScanOperator.Between, startDate, endDate ));
If the user selects from the calendar the start date as "08-20-2018" (2018-08-20T04:00:00.000Z) and the end date is "08-21-2018"(2018-08-21T04:00:00.000Z), the code all the data created b/w these 2 dates.
Now the issue is if they select same start and end date then the code does not returns any data, I believe because the start and end date is "2018-08-21T04:00:00.000Z" and the time part of this is all 0000 etc.
My question is how can I convert the date from my calendar ie my end date to correctly reflect the the end time which they select. I havent used ISO8601 format before so not sure how can I do so.
Thanks
You don't need moment for this. You can zero out the time using a Date in the following way.
const date = new Date('2018-08-21T12:58:08.7823906Z')
date.setUTCHours(0)
date.setUTCMinutes(0)
date.setUTCSeconds(0)
date.setUTCMilliseconds(0)
Then you can simply use toISOString() to format the date.
date.toISOString()
// returns '2018-08-21T00:00:00.000Z'
If you don't want to zero out the time, and instead want to set some specific time, you can use a similar approach, just substitute the 0 with whatever time you want.
Some other things to note: DynamoDB doesn't require any specific formatting for dates. DynamoDB simply does a string or number comparison depending on what the field is defined as. You could store your dates in DynamoDB as integers or another string format if you feel that would be easier to work with.
Also, I'm not sure how your table is setup but make sure that your "CreateOn" field is the Range key and that you are using Query, not Scan. Using the Scan operation doesn't scale well.

Resources