Functions in Sigma Computing
Functions in Sigma: A Simple Guide to Enhance Your Data Analysis
In the world of data analytics, the ability to manipulate and transform data is essential. Whether you're working with raw data, transforming it into a more readable form, or calculating insights for business decisions, functions are the key to simplifying these tasks. One of the tools that make working with data easier is Sigma, a powerful cloud-native data analytics platform. In this blog, we'll dive into the various functions in Sigma, demonstrate how they work, and show you how to use them to improve your data analysis workflow.
Understanding Functions in Sigma
Functions in Sigma are similar to functions in other data analysis platforms like Excel or SQL. They perform specific tasks like calculations, transformations, and aggregations to help you extract meaningful insights from your data. Sigma provides a rich set of functions, ranging from basic mathematical operations to more complex statistical functions, string manipulation, and even date-related functions.
Types of Functions in Sigma
Sigma’s functions can be broadly categorized into the following types:
- Mathematical Functions: These are functions that perform calculations such as addition, subtraction, multiplication, division, and advanced mathematical operations.
- String Functions: These functions are used to manipulate strings of text in your dataset. They can concatenate strings, extract substrings, replace characters, and more.
- Date and Time Functions: Functions related to manipulating and calculating time and date values. They help you with tasks like extracting parts of a date (year, month, day), calculating durations, or converting time zones.
- Aggregation Functions: These are used to aggregate data based on some grouping criteria. They include functions like SUM(), COUNT(), MAX(), and AVG(), which are used to calculate summary statistics.
- Conditional Functions: Conditional functions allow you to perform actions based on a condition. Functions like IF() and CASE WHEN can be used to evaluate whether certain criteria are met and return different values based on that.
In addition to these, Sigma also offers several other specialised categories of functions, which we'll explore below:
- Financial Functions: These functions are designed to help with financial analysis, such as calculating loan payments, interest rates, and other financial metrics.
- Geography Functions: These functions work with geospatial data, allowing you to analyze locations, distances, and other geographic-related tasks.
- Join Functions: Join functions help you combine data from different tables or datasets based on a common key or condition, allowing for more complex analysis.
- Window Functions: These functions enable you to perform calculations across a set of rows related to the current row within a window of data, often used for ranking, cumulative totals, and moving averages.
- Passthrough Functions: These functions allow you to pass data directly to another system or tool without any transformation, helping you to integrate Sigma seamlessly with external services.
- System Functions: These functions are related to system operations, providing access to metadata, system information, and performing other internal operations.
Mathematical Functions in Sigma
Mathematical functions are some of the most frequently used functions in Sigma. These functions are handy for performing basic arithmetic operations or more advanced calculations.
Basic Arithmetic
Sigma allows you to perform simple arithmetic calculations using functions like +, -, *, and /.
Example: Suppose you have a dataset with Revenue and Cost columns, and you want to calculate the profit.
In Sigma, you can use the formula:

This formula subtracts the Cost from Revenue to give you the Profit. You can apply this across your entire dataset.
Advanced Mathematical Functions
You can also use advanced mathematical functions such as ROUND(), POWER(), SQRT(), and more.
For instance, if you wanted to calculate the square root of the Profit column, you would write:

This is useful when dealing with datasets that require more sophisticated analysis, such as financial data or scientific computations.
String Functions
String functions help you manipulate text-based data. These functions are helpful when you need to clean, format, or extract specific parts of a string.
Concatenation
If you need to combine two columns into a single string, you can use the CONCAT() function.
Example: Suppose you have a First Name and a Last Name column, and you want to create a Full Name column.

This will concatenate the first and last names, separated by a space.
Substring Extraction
If you need to extract a specific part of a string, you can use the SUBSTRING() function.
Example: Suppose you have a Phone Number column and want to extract the area code, which is the first three characters.

This extracts the first three characters from the Phone Number column and labels it as Area Code.
Date and Time Functions
Working with dates and times is an essential part of data analysis. Sigma offers several functions to help you extract parts of a date, manipulate date values, and perform time-based calculations.
Extracting Date Parts
If you need to extract a specific part of a date (e.g., the year, month, or day), you can use functions like YEAR(), MONTH(), and DAY().
Example: If you have a Date column and want to extract the year, you can write:

This function will return the year from the Date column.
Date Differences
You can calculate the difference between two dates using the DATEDIFF() function. This is useful for calculating durations or time intervals.
Example: If you want to calculate the number of days between Start Date and End Date, you can use:

This will return the difference in days between the two dates.
Aggregation Functions
Aggregation functions are used to summarize data, often in combination with grouping. These functions allow you to perform operations like summing values, calculating averages, and counting rows.
SUM and AVG
For example, if you have a Sales column and want to calculate the total sales and average sales, you would use:

These will return the sum and average of the Sales column.
COUNT
The COUNT() function is used to count the number of rows in a dataset or the number of non-null values in a specific column.

This counts all the rows in your dataset.
Conditional Functions
Conditional functions are useful when you want to perform different actions based on specific conditions. Sigma supports IF() and CASE WHEN functions for these tasks.
IF Function
The IF() function allows you to evaluate a condition and return different results based on whether the condition is true or false.
Example: If you want to classify Sales as "High" or "Low" based on whether they are above or below 1000, you can use:

This will create a new column that categorizes each row's sales as "High" or "Low."
CASE WHEN Function
The CASE WHEN function is more flexible than IF() and allows for multiple conditions.
Example: If you want to categorize Sales into "Low," "Medium," and "High" based on different thresholds, you could use:

this will create a Sales Category column with the appropriate label based on the value of Sales.
Additional Categories of Functions
Financial Functions
Sigma offers a set of financial functions designed for performing common financial calculations, such as determining loan payments, interest rates, and cash flow analysis. Functions like PMT() for calculating loan payments and FV() for calculating the future value of an investment are essential for financial modeling.
Example: To calculate a loan payment with a 5% interest rate, you could use:

Geography Functions
Geography functions allow you to work with spatial data, such as distances, areas, and locations. These functions are useful for analyzing geographic trends, like customer proximity or delivery routes.
Example: To calculate the distance between two latitude/longitude points, you can use the DISTANCE() function:

This function calculates the distance between two geographic locations.
Join Functions
Join functions are essential for combining data from multiple tables. Using JOIN(), you can merge tables based on a common key, allowing you to analyze data across different datasets.
Example: If you want to join a Customers table with an Orders table based on Customer ID, you would use:

This merges the data based on the shared CustomerID key.
Window Functions
Window functions are powerful for performing calculations over a set of rows that are related to the current row, often used for ranking or cumulative totals. These functions are commonly used for operations like calculating moving averages or cumulative sums.
Example: To calculate the running total of Sales, you would use:

This will return a running total of Sales, ordered by the Date column.
Passthrough Functions
Passthrough functions allow you to pass data directly to another system or tool without any transformation. These are useful for integrating Sigma with other applications, such as sending data to external APIs or databases.
Example: If you want to send data directly to an external database, you might use a passthrough function like:

This sends the Data column without alteration.
System Functions
System functions give you access to system-level information, like metadata or current date and time. These are useful for auditing, logging, or getting system-related values.
Example: To get the current date and time in Sigma, you can use:

This will return the current system timestamp.
Conclusion
Sigma provides a wide range of powerful functions that make data analysis and manipulation easier for users with varying technical expertise. From basic mathematical operations to complex financial calculations and geospatial analysis, the functions in Sigma are designed to be both intuitive and powerful.
In this blog, we’ve covered several categories of Sigma functions: mathematical, string, date-time, aggregation, conditional, financial, geography, join, window, passthrough, and system functions. Each of these functions has its place in helping you work with your data efficiently, whether you're cleaning, transforming, or analyzing it.
By incorporating these functions into your data workflow, you can unlock deeper insights, save time, and make better-informed decisions. Whether you're an analyst, data scientist, or business user, mastering Sigma's functions will enhance your ability to work with data and drive business success.
With these functions, you're equipped to handle complex data challenges and make the most of your data analysis projects. Happy analyzing!