This is a listing of all of the functions that you can use in making your own calculated fields.
If you want to know how to make your own calculated fields, there is a video about it here.
You can scroll horizontally to view all the data from a column.
Function Name | Description | Output Type | Formatting |
---|---|---|---|
AND |
Returns TRUE when both expressions are TRUE, otherwise returns FALSE. This is most commonly used as part of an IF or CASE statement. |
TRUE, FALSE |
expression_one = 'x' AND expression_two = 'y' CASE |
AVG | Returns the average of a set of values. | Numeric | AVG([DataWarehouse].[dm].[TimeRecord].[TotalHours]) |
BETWEEN |
Returns TRUE if the test value is equal to or between the two expression values. This is most commonly used as part of an IF or CASE statement. |
TRUE, FALSE |
BETWEEN(test_value, start_expression,end_expression) IF( |
CASE…WHEN | Returns the value of the result expression if the test expression is true, otherwise, return the else expression. | The data type returned is the data type of the return expression(the expression after the THEN) |
CASE WHEN (test_expression) THEN result_expression ELSE else_expression END CASE WHEN( [DataWarehouse].[dm].[UserTranscript].[CourseTitle]= 'CPR' ) THEN 'Bi-AnnualHealth' WHEN( [DataWarehouse].[dm].[UserTranscript].[CourseTitle] ='Forklift' ) THEN 'AnnualSafety' ELSE 'Annual Other' END |
CAST…AS |
Converts an expression from one data type to another. You can use either this or the CONVERT function. |
CAST(expression AS new_data_type) CAST('06/16/1966' AS DATETIME) |
|
CONCAT | Joins values together as text. | Text string |
CONCAT(string_1, string_2) CONCAT([DataWarehouse].[dm].[Job].[JobTitle], ' - ',[DataWarehouse].[dm].[Job].[RequisitionCode]) |
CONVERT |
Converts an expression from one data type to another. You can use either this or the CAST…AS function. |
CONVERT(new_data_type, expression) CONVERT(DATETIME, '06/16/1966') |
|
COUNT | Returns the total number of items in a group. | Numeric |
COUNT(field) COUNT([DataWarehouse].[dm].[JobCandidate].[JobCandidateId]) |
DATEADD |
Returns the date field plus the provided increment number. datepart: the part of the date; ex day, month, year). See the Date Part table below |
Datetime |
DATEADD(datepart,increment_number, date_field) DATEADD(yyyy, 2,[DataWarehouse].[dm].[User].[HireDate]) DATEADD(mi, -17,[DataWarehouse].[dm].[TimeRecord].[StopDatetime]) |
DATEDIFF |
Returns the number of date units (like minutes, hours, ormonths) between two dates. datepart: the part of the date; ex day, month, year). See the Date Part table below start_datetime, end_datetime: two date fields |
Numeric |
DATEDIFF(datepart, start_datetime, end_datetime) DATEDIFF(dd,[DataWarehouse].[dm].[UserLearningPlan].[AssignedDate],GETDATE()) |
DATEPART |
Returns part of a supplied date field. datepart: the part of the date; ex day, month, year). See the Date Part table below date_field: date field from one of the tables in the report |
Numeric |
DATEPART(datepart, date_field) DATEPART(yyyy, [DataWarehouse].[dm].[User].[DateOfBirth]) |
DISTINCT |
Returns unique values that are listed in a field. This would typically be used within another function, like SUM or COUNT. |
Returns the data type of the return values. |
DISTINCT(field) COUNT( DISTINCT([DataWarehouse].[dm].[User].[Department]) ) This returns the number of unique departments |
GETDATE | Returns the current date and time. | Datetime | GETDATE() |
IF…THEN |
Returns the value of the true_expression of theboolean_expression is TRUE, otherwise returns the value of thefalse_expression. If you have multiple values that you want to test for you can embed an IF statement with another IF statement as many times as you have conditions as you need to check for. Using the CASE statement is probably going to be easier to build and troubleshoot than this option. |
Returns the data type of the return expressions. |
IF (boolean_expression) THEN (true_expression) ELSE (false_expression) END IF ([User].[City] = 'New York') THEN 'Apple' ELSE 'not a fruit' END IF ( [TimeRecord].[TotalHours] < 3) THEN 'Part Time' ELSE( IF (BETWEEN ( [TimeRecord].[TotalHours] , 4, 8) ) THEN 'Full Time' ELSE 'Overtime' END ) END |
IIF | If an expression is TRUE it returns the first value. If the expression is FALSE it returns the second value. | Returns the data type of the return values. |
IIF(logical expression, first_value, second_value) IIF( [DataWarehouse].[dm].[UserLearningPlan].[TaskStatus] = 'Completed', 'OK', [DataWarehouse].[dm].[UserLearningPlan].[TaskStatus] ) |
ISNULL |
Checks to see if a field is NULL. If it is NULL then it returns the value of the replacement expression. If it is not NULL then it returns the value of the original field. Note, that in Analytics many of the fields, except for dates, that would normally be NULL have been replaced with blanks. In those cases, you should use an IIF, CASE, or IF statement to see if a field is blank. |
The reurn data type is the same as the data type of the fieldbeing checked. |
IIF(logical expression, first_value, second_value) IIF( [DataWarehouse].[dm].[UserLearningPlan].[TaskStatus] = 'Completed', 'OK', [DataWarehouse].[dm].[UserLearningPlan].[TaskStatus] ) |
LEN | Returns the number of characters of a given text field, including spaces. | Numeric |
LEN(field) LEN([DataWarehouse].[dm].[User].[AddressLine1]) |
MAX | Returns the maximum value in a group. | The same data type as the field. |
MAX(field) MAX([DataWarehouse].[dm].[TimeRecord].[WorkDate]) This returns the maximum date clocked in or out. MAX([DataWarehouse].[dm].[TimeRecord].[TotalHours]) This returns the greatest number of total hours. |
MIN | Returns the minimum value in a group. | The same data type as the field. |
MIN(field) MIN([DataWarehouse].[dm].[TimeRecord].[WorkDate]) This returns the minimum date clocked in or out. MIN([DataWarehouse].[dm].[TimeRecord].[TotalHours]) This returns the lowest number of total hours. |
OR | Returns TRUE when any expression is TRUE, Otherwise returns FALSE. This is most commonly used as part of an IF or CASE statement. |
Boolean |
expression_one OR expression_two OR expression_three CASE WHEN( [DataWarehouse].[dm].[User].[Department] = 'Concrete' OR [DataWarehouse].[dm].[User].[ManagerUserName] = 'Bob' ) THEN 'Construction' ELSE 'Maintenance' END |
ROUND | Returns the original expression, rounded to the specified number of decimal places. Use a decimal_value of 0 to round to the nearest whole number. | Numeric |
ROUND(field, decimal_value) ROUND([DataWarehouse].[dm].[TimeRecord].[TotalHours], 3) |
RUNNINGAVG | Returns the average of all values of the expression from the first row up to the current row. | The same data type as the field. |
RUNNINGAVG(field) RUNNINGAVG([DataWarehouse].[dm].[TimeRecord].[RegularTimeHours]) For a date set that looks like this it would return the following values: DAY, HOURS, RETURN MON,8,8 TUE, 10, 9 WED, 8, 8.67 THU, 6, 8 FRI, 4, 7.2 |
RUNNINGCOUNT | Returns the row count. | Numeric |
RUNNINGCOUNT(field) RUNNINGCOUNT( [DataWarehouse].[dm].[TimeRecord].[RegularTimeHours] ) For a date set that looks like this it would return the following values: DAY, HOURS, RETURN MON, 8, 1 TUE, 10, 2 WED, 8, 3 THU, 6, 4 FRI, 4, 5 |
RUNNINGSUM | Returns the sum of all values of the expression from the first row up to the current row. | Numeric |
RUNNINGSUM(field) RUNNINGCOUNT( [DataWarehouse].[dm].[TimeRecord].[RegularTimeHours] ) For a date set that looks like this it would return the following values: DAY, HOURS, RETURN MON, 8, 8 TUE, 10, 18 WED, 8, 26 THU, 6, 32 FRI, 4, 36 |
SUM | Returns the sum of all the values in group. Blank and NULL values are ignored. | Numeric |
SUM(field) SUM( [DataWarehouse].[dm].[TimeRecord].[RegularTimeHours] ) |
Data Types
You can use these data types in the CONVERT or CAST...AS functions.
Data Types | Description |
---|---|
Boolean | True or False |
Datetime | Date and time |
Money | A number with a decimal. If you just have a number with a decimal, whether it is related to currency or not, use money; ie 3.14 |
Numeric | A number without a decimal |
Text | Any alphabetical or numeric value. This can include values such as 'pizza', '3.14', 'True' |
Date Parts
When using any of the date functions you can use the full date part names or the below abbreviations. All of the date parts are returned as numbers.
If you just want to display the year, month, day of week, etc., you can Format the date by selecting the field and modifying it in Field Properties.
Date Part | Abbreviations |
---|---|
year | yy, yyyy |
quarter | qq, q |
month | mm, m |
dayofyear | dy, y |
day | dd, d |
week | ww, wk |
weekday | dw |
hour | hh |
minute | mi, n |
second | ss, s |
millisecond | ms |