Mastering the SECOND Function in Looker Studio: Extraction, Usage, Examples, and Limitations

 Mastering the SECOND Function in Looker Studio: Extraction, Usage, Examples, and Limitations

Discover the power that hides within the

SECOND
function in Google Data Studio. Used to extract the seconds component from a given date, the
SECOND
function simplifies the time analysis process by allowing you to isolate and observe the seconds part of your data. This function is especially handy when you're dealing with precise time-based metrics or when you need granular-level details.

Syntax

The

SECOND
function carries two types of syntax:

  1. This syntax is utilized when we want to extract the seconds component from a Date & Time value:

    SECOND(datetime_expression)
    The
    datetime_expression
    can be either a Date & Time field or expression.

  2. This syntax is used for compatibility mode Date value extraction. In addition,

    Input Format
    is optionally provided in case X isn't appropriately configured as a semantic date field:
    SECOND(X [,Input Format])
    Here,
    X
    can be a field or expression resulting in Text, Number, or compatibility mode Date. The
    Input Format
    is used to properly interpret the compatibility mode dates.

The

SECOND
function supports various input formats for compatibility mode dates, ranging from 'BASIC', 'DEFAULT_DASH', 'DEFAULT_SLASH', to specific formats like 'RFC_1123', 'RFC_3339', and 'DECIMAL_DATE'. For Numeric fields or expressions, it accepts 'SECONDS', 'MILLIS', 'MICROS', 'NANOS', and 'JULIAN_DATE'.

Usage

Although the Google Data Studio

SECOND
function seems simple, it's a powerful tool to use when dealing with precise time data. To use the function, simply place your Date & Time field or expression within the parentheses (), or for compatibility mode dates, provide your field/expression and optionally, the Input Format.

Examples

Say, you run an online store and want to analyze the precise time when a purchase was made. You have the transaction timestamp which you want to break down.

  1. To get the seconds part from a date-time expression that is timestamp of the transaction:

SECOND(Transaction_timestamp)

  1. Suppose the timestamp is in text format like "2022/01/01-14:20:45". To get the seconds:

SECOND("2022/01/01-14:20:45", 'BASIC')

  1. When the timestamp is stored as milliseconds since the Epoch:
    SECOND(Transaction_timestamp_millis, 'MILLIS')

Remember, the function will return a result between 0-59 which represents the seconds component of the date.

Function Limitations

Keep in mind that the

SECOND
function is designed to only retrieve the 'seconds' portion of a dateime. It won't return minutes, hours, or any other components. Also, it works with both compatibility mode dates and upgraded Date and Date & Time data types.

Helpful Tips

Some tips to keep in mind:

  • Make sure to match the correct input format with the data type of your source field or expression.
  • Deployment of the
    SECOND
    function can be especially beneficial when coupled with other time-based functions for comprehensive time-series analysis.
  • Use
    SECOND
    function in calculated fields to create new metrics at granular level.

Remember, every second counts, and so does the

SECOND
function in Google Data Studio! Compute wisely!

More function to use with Looker Studio

COS
:
Looker Studio Studio's Magnificent Cosine Functionality
TOCOUNTRY
:
Understanding and Using the TOCOUNTRY Function in Looker Studio for Enhanced Data Reporting
ASIN
:
Taking Advantage of Google Data Studio's ASIN Function
SUM
:
Mastering the SUM Function: A Detailed Guide to Calculating Large Datasets with Looker Studio
CONTAINS_TEXT
:
Introduction to the CONTAINS_TEXT Function