Functions
Functions play a key role in data manipulation and transformation in PandaSuite. They allow you to perform specific operations on different data types, such as numbers, strings, dates, and arrays.
Understanding the Role of Functions
A function takes parameters that determine its behavior. These parameters specify the data the function should act on and may include operation-specific options. Once executed, the function returns a result that can be used in the application.
Some functions are only compatible with specific data types. For example, a mathematical function cannot be applied to a string without prior conversion.
General Functions
Evaluate
Evaluates an expression and returns the result.
Parameter: Expression (string containing a mathematical or logical operation)
Returns: True or false
By Key
Returns the value of an item based on its key.
Parameter: Key
Returns: Value associated with the key
By Index
Returns the value of an item based on its index (the first element is indexed at 0).
Parameter: Index
Returns: Value at the given index
By Id
Returns the value of an item based on its unique identifier.
Parameter: Identifier
Returns: Associated value
Mathematical Functions
Mathematical functions take a number as a parameter.
💡 If you use the value from a Text Input component, be sure to use the Parse Number function to convert the value before performing operations.
Add
Adds the specified number in the parameter and returns the value.
Subtract
Subtracts the specified number in the parameter and returns the value.
Multiply
Multiplies by the specified number in the parameter and returns the value.
Divide
Divides by the specified number in the parameter and returns the value.
Round
Rounds to the nearest integer.
Floor
Returns the largest integer less than or equal to a specified number.
Ceil
Returns the smallest integer greater than or equal to a specified number.
Sqrt
Returns the square root of a number.
Cbrt
Returns the cube root of a number.
Tan
Returns the tangent of a number expressed as an angle in radians.
Cos
Returns the cosine of an angle expressed in radians.
Sin
Returns the sine of a number.
Pow
Returns a number raised to a given power.
Abs
Returns the absolute value of a number.
Format Number
Returns a number in the requested format.
Parameters:
- Minimums (Fractions): The minimum number of decimals to use
- Maximums (Fractions): The maximum number of decimals to use
💡 Reference documentation: NumberFormat
Parse Number
Converts a string to a number.
Parse Color
Text Functions
Truncate
Truncates text to the specified number of characters.
Split
Splits a text into an array using a defined separator.
Date and Time Functions
Format Date
Converts a date into a string according to a given format.
You can choose between predefined and custom date and time formats.
Predefined Types
Here are the available parameters for the Predefined type:
- Date Style: Choose between None, Short, Medium, Long, Full
Example with the date September 16, 2021, at 4:53 PM:
None | The date is not displayed |
---|---|
Short | 9/16/21 |
Medium | Sep 16, 2021 |
Long | September 16, 2021 |
Full | Thursday, September 16, 2021 |
- Time Style: Choose between None, Short, Medium, Long, Full
Example with the same date:
None | The time is not displayed |
---|---|
Short | 4:53 PM |
Medium | 4:53:15 PM |
Long | 4:53:15 PM GMT+2 |
Full | 4:53:15 PM Central European Time |
- Time Zone: Choose the reference time zone
Custom Types
Here are the available parameters for the Custom type:
- Date/Time Format: You can choose a custom format using universal Timestamp codes.
Commonly used codes:
Code | Description |
---|---|
yyyy | Year in 4 digits (e.g., 2023) |
MM | Month in 2 digits (e.g., 07 for July) |
dd | Day in 2 digits (e.g., 07) |
HH | Hour in 2 digits, 24-hour format |
hh | Hour in 2 digits, 12-hour format |
mm | Minutes in 2 digits |
tt | A.M. or P.M. in two letters |
💡 Find all codes here: Date/Time Formatting
- Time Zone: Choose the reference time zone
Parse Date
Parses a string containing a date and returns the date.
Add Seconds/Minutes/Hours/Days/Months/Years
Adds or subtracts a specific duration from a date.
Set Seconds/Minutes/Hours/Days/Months/Years
Replaces a part of the date with a new value.
Array and Collection Functions
Merge
Merges two collections into one.
Count
Returns the number of elements in an array.
Group by
Groups data based on a given criterion.
Uniq by
Removes duplicates based on a given criterion.
Min
Returns the minimum value of array.
Min By
Returns the object that has the minimum value (from collection).
Max
Returns the maximum value of array.
Max By
Returns the object that has this maximum value (from collection).