﻿ Google Data Studio Functions, Formulas Tutorial - Optimize Smart

# Google Data Studio Functions, Formulas Tutorial

Functions in Google Data Studio are formulas which are used to:

• Aggregate data.
• Do mathematical calculations on your data.
• Manipulate time data.
• Manipulate geographic location data.
• Manipulate string data.

Functions make your calculated fields more powerful. They are used inside of calculated fields as a formula.

If you remember, we used the ‘CASE’ function as a formula when dealing with boolean values: ‘CASE’ is just one of the many functions provided by Google Data Studio.

Google Data Studio provides over 50 functions that you can use inside of calculated fields as a formula.

Following are the typical attributes of a function in Google Data Studio

1. Every function in Data Studio has some purpose.
2. Every function in Data Studio has syntax
3. All functions expect one or more parameters
4. Parameters are listed in the syntax
5. All functions return a value
6. Almost all functions have certain restrictions regarding how they can be used.

## #1 Every function in Data Studio has some purpose

For example, the ‘CASE’ function is used to create new fields that use conditional logic to determine the field values.

The ‘AVG’ function is used to calculate the average value of a numeric field.

Similarly, the ‘COUNT’ function is used to count the number of items in a field.

## #2 Every function in Data Studio has syntax

Syntax defines how a function must be used. It defines how parameters (more about them later) must be used.

For example, the following is the syntax for the CASE function:

CASE

WHEN condition THEN result

WHEN condition THEN result

WHEN condition THEN result

…

ELSE result

END

Following is the syntax for ‘AVG’ function:

AVG(value)

Following is the syntax for ‘COUNT’ function:

COUNT(value)

## #3 All functions expect one or more parameters

Parameters (also called ‘arguments’) are the input a function expects in Google Data Studio. The parameter tells the function of what data to act upon.

Parameters can be field names or expressions.

An expression can be a number, literal text, or a statement that evaluates to a field name in your data source.

Parameters can also provide additional instructions or formatting information.

For example, CASE function expects the following parameters:

1. Condition
2. Result
3. Else result

#1 Condition—It is an expression which evaluates to a boolean value (true or false). Conditions can include dimensions or metrics but not both: #2 Result – the value to return. It can be a dimension, metric, or literal value: #3 ELSE result (optional) – It is the default value to return if no other condition is met.

Note(1): When providing parameters, be sure to enclose the literal text in single or double-quotes.
Note(3): You can click on the ‘Format Formula’ button, to make your formula more readable.  ## #4 Parameters are listed in the syntax

All the parameters which the CASE function expect, are listed in the syntax of the CASE function:

CASE

WHEN condition THEN result

WHEN condition THEN result

WHEN condition THEN result

…

ELSE result

END

So if you remember the syntax, you would remember how to use the CASE function.

## #5 All functions return a value

For example, ‘CASE’ function returns dimensions or metrics based on conditional expressions.

The ‘AVG’ function returns the average for all values in a field or expression.

Similarly, the COUNT function returns the total number of items in a field or expression.

## #6 Almost all functions have certain restrictions regarding how they can be used

For example, when using the CASE function you can not compare dimensions to dimensions or metrics to metrics: In Data Studio, you can compare a dimension or metric only with a literal value.

Similarly, you can not apply the AVG function or COUNT function to a pre-aggregated field.

### More information on each function, including examples, is also available in the formula editor.

When you type a function name in the formula editor, Data Studio provides information about the function like its syntax, its purpose and its use case: The bottom of the formula editor sometimes provides additional information about how a function is being used and how it should be used.

For example, in the screenshot above, the Data Studio was expecting arguments (Expected arguments, but none were provided).

## Types of Data Studio functions

All of the Data Studio functions are grouped into the following categories:

1. Aggregation functions
2. Arithmetic functions
3. Date functions
4. Geo functions
5. Text functions
6. Miscellaneous functions

## Aggregation functions

These functions are used to aggregate data.

Following are examples of aggregation functions:

Note: Aggregation functions can not be applied to already aggregated data. This includes most metrics found in Google Analytics and Google Ads. For example, Sessions is already summed in your data set, so the formula SUM(Sessions) will produce an error.

## Arithmetic functions

These functions are used to do mathematical calculations on your data.

Following are examples of Arithmetic functions:

## Date functions

These functions are used to manipulate time data.

Following are examples of Date functions:

Note: Date functions assume UTC as their timezone. Date functions can optionally take either an input or output (or both) format string.

## Geo functions

These functions are used to manipulate geographic location data.

Following are examples of Geo functions:

## Text functions

These functions are used to manipulate string data.

Following are examples of text functions:

## Miscellaneous functions

Functions which do not fall in any of the below categories come under the ‘miscellaneous functions’ category:

1. Aggregation functions
2. Arithmetic functions
3. Date functions
4. Geo functions
5. Text functions

Following are the examples of miscellaneous functions:

### What are functions in Google Data Studio?

Functions in Google Data Studio are formulas which are used to manipulate data, aggregate data and do mathematical calculations on data.

Functions make your calculated fields more powerful. They are used inside of calculated fields as a formula.

### How many functions does Google Data Studio provide?

Google Data Studio provides over 50 functions that you can use inside of calculated fields as a formula.

### What are the attributes of a function in Google Data Studio?

Following are the typical attributes of a function in Google Data Studio
– Every function in Data Studio has some purpose.
– Every function in Data Studio has syntax
– All functions expect one or more parameters
– Parameters are listed in the syntax
– All functions return a value
– Almost all functions have certain restrictions regarding how they can be used.

### What types of functions are available in Google Data Studio?

All of the Data Studio functions are grouped into the following categories:
– Aggregation functions
– Arithmetic functions
– Date functions
– Geo functions
– Text functions
– Miscellaneous functions

## "How to use Digital Analytics to generate floods of new Sales and Customers without spending years figuring everything out on your own."

Here’s what we’re going to cover in this training…

#1 Why digital analytics is the key to online business success.

​#2 The number 1 reason why most marketers are not able to scale their advertising and maximize sales.

#4 ​Why you won’t get any competitive advantage in the marketplace just by knowing Google Analytics.

#5 The number 1 reason why conversion optimization is not working for your business.

​#7 How to learn and master digital analytics and conversion optimization in record time.

## My best selling books on Digital Analytics and Conversion Optimization

Maths and Stats for Web Analytics and Conversion Optimization
This expert guide will teach you how to leverage the knowledge of maths and statistics in order to accurately interpret data and take actions, which can quickly improve the bottom-line of your online business.

Master the Essentials of Email Marketing Analytics
This book focuses solely on the ‘analytics’ that power your email marketing optimization program and will help you dramatically reduce your cost per acquisition and increase marketing ROI by tracking the performance of the various KPIs and metrics used for email marketing.

Attribution modelling is the process of determining the most effective marketing channels for investment. This book has been written to help you implement attribution modelling. It will teach you how to leverage the knowledge of attribution modelling in order to allocate marketing budget and understand buying behaviour. 