Vendor Specific Functions Constants A constant is a fixed value that you can use in an expression. Operators Operators specify what happens to the values on either side of the operator. Operators are similar to functions, in that they manipulate data items and return a result. date Inserts the current system date. date-time Inserts the current system date and time. time with time zone Inserts a zero time with time zone. timestamp with time zone Inserts an example of a timestamp with time zone. Inserts false value. interval Inserts a zero interval: 000 00:00:00.000. interval year Inserts a zero year interval: 0 year. interval month Inserts a zero month interval: 0 month. interval year to month Inserts a zero year to month interval: 0000-00 year to month. interval day Inserts a zero day interval: 0 day. interval hour Inserts a zero hour interval: 0 hour. interval minute Inserts a zero minute interval: 0 minute. interval second Inserts a zero second interval: 0 second. interval day to hour Inserts a zero day to hour interval: 0 00 day to hour. interval day to minute Inserts a zero day to minute interval: 0 00:00 day to minute. interval day to second Inserts a zero day to second interval: 0 00:00:00.000000000 day to second. interval hour to minute Inserts a zero hour to minute interval: 00:00 hour to minute. interval hour to second Inserts a zero hour to second interval: 00:00:00.000000000 hour to second. interval minute to second Inserts a zero minute to second interval: 00:00.000000000 minute to second. Inserts "null" if the expression conditions are not met. number Inserts the number 0, which can be replaced with a new numeric value. string Inserts an empty string as two single quotation marks between which you can type a string. time Inserts the current system time. Inserts true value.
Identifies the beginning of an expression. ( expression ) Identifies the end of an expression. ( expression ) Multiplies two numeric values. value1 * value2 , Separates expression components. expression ( parameter1, parameter2 ) Divides two numeric values. value1 / value2 Concatenates, or joins, strings. string1 || string2 Adds two numeric values. value1 + value2 Subtracts two numeric values or negates a numeric value. value1 - value2 or - value Compares the values that are represented by "value1" against "value2" and retrieves the values that are less than "value2". value1 < value2 Compares the values that are represented by "value1" against "value2" and retrieves the values that are less than or equal to "value2". value1 <= value2 Compares the values that are represented by "value1" against "value2" and retrieves the values that are not equal to "value2". value1 <> value2 Compares the values that are represented by "value1" against "value2" and retrieves the values that are equal to "value2". value1 = value2 Compares the values that are represented by "value1" against "value2" and retrieves the values that are greater than "value2". value1 > value2 Separates the components in a literal member expression. [namespace].[dimension].[hierarchy].[level]->[L1] Compares the values that are represented by "value1" against "value2" and retrieves the values that are greater than or equal to "value2". value1 >= value2 Returns "true" if the conditions on both sides of the expression are true. argument1 and argument2 Works with summary expressions to define the scope to be adjusted based on the grouping columns in the query. The scope is context-dependent. aggregate_function ( expression AUTO ) Determines if a value falls in a given range. expression between value1 and value2 Example: [Revenue] between 200 and 300 Result: Returns the number of results with revenues between 200 and 300. Revenue Between ---- ---- $332.06 false $230.55 true $107.94 false Works with when, then, else, and end. Case identifies the beginning of a specific situation, in which when, then, and else actions are defined. case expression { when expression then expression } [ else expression ] end Determines if "string1" contains "string2". This syntax supports both metacharacters: The percent sign (%) represents zero, one or multiple characters, and the underscore sign (_) represents any character. The optional LITERAL keyword indicates how '%' and '_' are interpreted. When the LITERAL keyword is present, '%' and '_' are not to be treated as metacharacters (see Example 3 and 5). Otherwise, in the absence of the LITERAL keyword, '%' and '_' behave as metacharacters (see Example 1, 2 and 4). string1 contains [LITERAL] string2 Example 1: [PRODUCT_LINE] contains 'door' Result 1: Outdoor Equipment Example 2: [PRODUCT_LINE] contains 'Golf%' Result 2: Golf Equipment Example 3: [PRODUCT_LINE] contains literal 'Golf%' Result 3: Golf% Example 4: [PRODUCT_LINE] contains 'Current_Year%' Result 4: Current Year Price, Current Year Price%, Current_Year Price%. Example 5: [PRODUCT_LINE] contains literal 'Current_Year%' Result 5: Current_Year%. Keyword that can be used as the first argument of member summary functions. This function appears in the Total Revenue by Country sample report in the GO Data Warehouse (query) package. aggregate_function ( currentMeasure within set expression ) current_date Returns the current date of the database. current_date Works with the lookup construct. lookup (....) in (....) default (....) A keyword used in an aggregate expression to include only distinct occurrences of values. See also the function unique. distinct dataItem Example: count ( distinct [OrderDetailQuantity] ) Result: 1704 Works with the if or case constructs. If the if condition or the case expression are not true, then the else expression is used. This function appears in the Top 10 Retailers for 2005 sample report in the GO Data Warehouse (analysis) package. if ( condition ) then .... else ( expression ) , or case .... else ( expression ) end Indicates the end of a case or when construct. case .... end Determines if "string1" ends with "string2". This syntax supports both metacharacters: The percent sign (%) represents zero, one or multiple characters, and the underscore sign (_) represents any character. The optional LITERAL keyword indicates how '%' and '_' are interpreted. When the LITERAL keyword is present, '%' and '_' are not to be treated as metacharacters (see Example 3 and 5). Otherwise, in the absence of the LITERAL keyword, '%' and '_' behave as metacharacters (see Example 1, 2 and 4). string1 ends with [LITERAL] string2 Example 1: [PRODUCT_LINE] ends with 'Equipment' Result 1: Camping Equipment, Golf Equipment Example 2: [PRODUCT_LINE] ends with '%Equipment' Result 2: Golf Equipment, Camping Equipment Example 3: [PRODUCT_LINE] ends with literal 'Equipment%' Result 3: Equipment% Example 4: [PRODUCT_LINE] ends with '%Price' Result 4: Product Price, Current_Year Price Example 5: [PRODUCT_LINE] ends with literal '%Price' Result 5: %Price Determines if "string1" matches the pattern of "string2", with the character "char" optionally used to escape characters in the pattern string. string1 LIKE string2 [ ESCAPE char ] Example: [PRODUCT_LINE] like 'G%' Result: All product lines that start with 'G'. Example: [PRODUCT_LINE] like '%Ga%' escape 'a' Result: All the product lines that end with 'G%'. Works with summary expressions to define the scope of the aggregation in the query. aggregate_function ( expression for expression { , expression } ) Works with summary expressions to define the scope to be adjusted based on a subset of the grouping columns in the query. Equivalent to the for clause. aggregate_function ( expression for ANY expression { , expression } ) Works with summary expressions to define the scope to be all the specified grouping columns in the query. See also the for clause. aggregate_function ( expression for ALL expression { , expression } ) Works with summary expressions to set the scope to be the whole query. See also the for clause. This function appears in the Customer Returns and Satisfaction sample report in the GO Data Warehouse (analysis) package. aggregate_function ( expression for report ) Works with the then and else constructs. If defines a condition; when the if condition is true, the then expression is used. When the if condition is not true, the else expression is used. This function appears in the Top 10 Retailers for 2005 sample report in the GO Data Warehouse (analysis) package. if ( condition ) then ( expression ) else ( expression ) Determines if "expression1" exists in a given list of expressions. expression1 in ( expression_list ) Determines if "expression1" exists in a given list of constant values or ranges. expression1 in_range { constant : constant [ , constant : constant ] } Example: [code] in_range { 5 } Result: This is equivalent to [code] = 5. Example: [code] in_range { 5: } Result: This is equivalent to [code] >= 5. Example: [code] in_range { :5 } Result: This is equivalent to [code] <= 5. Example: [code] in_range { 5:10 } Result: This is equivalent to ( [code] >= 5 and [code] <= 10 ). Example: [code] in_range { :5,10,20: } Result: This is equivalent to ( [code] <= 5 or [code] = 10 or [code] >= 20 ). Determines if "value" is undefined in the data. value is missing Determines if "value" is undefined in the data. value is null Determines if "value" is defined in the data. value is not missing Determines if "value" is defined in the data. value is not null Determines if "string1" matches the pattern of "string2", with the character "char" optionally used to escape characters in the pattern string. This syntax supports both metacharacters: The percent sign (%) represents zero, one or multiple characters, and the underscore sign (_) represents any character. string1 LIKE string2 [ ESCAPE char ] Example 1: [PRODUCT_LINE] like 'G%' Result 1: All product lines that start with 'G'. Example 2: [PRODUCT_LINE] like '%Ga%' escape 'a' Result 2: All the product lines that end with 'G%'. Example 3: [PRODUCT_LINE] like 'C_R_' Result 3: All the product lines with the name CARS or CARD. Example: lookup ( [Country]) in ( 'Canada'--> ( [List Price] * 0.60), 'Australia'--> ( [List Price] * 0.80 ) ) default ( [List Price] ) Finds and replaces data with a value you specify. It is preferable to use the case construct. lookup ( name ) in ( value1 --> value2 ) default ( expression ) Returns TRUE if "argument" is false or returns FALSE if "argument" is true. NOT argument Returns TRUE if either of "argument1" or "argument2" are true. argument1 or argument2 Performs a summary calculation before applying the summary filter. summary_function ([expression] prefilter) Example: total ( [Quantity] for report prefilter ) summaryFilter: total( [Quantity] for [ProductNo] ) > 50000 Result: Sums the quantities in a report before the summary filter is applied. PNo Total Total Total forPNo forRep forRep_Prefilter --------- -------- ---------- ------------------- 88 54928 298140 2215354 89 51126 298140 2215354 90 69996 298140 2215354 94 69004 298140 2215354 95 53086 298140 2215354 Counts the number of rows output by the query. Use with Count (). count ( ROWS ) Counts the number of rows output by the query. Use with Count (). count ( ROWS  [ expression ]) Determines if "string1" starts with "string2". This syntax supports both metacharacters: The percent sign (%) represents zero, one or multiple characters, and the underscore sign (_) represents any character. The optional LITERAL keyword indicates how '%' and '_' are interpreted. When the LITERAL keyword is present, '%' and '_' are not to be treated as metacharacters (see Example 3 and 5). Otherwise, in the absence of the LITERAL keyword, '%' and '_' behave as metacharacters (see Example 1, 2 and 4). string1 starts with [LITERAL] string2 Example 1: [PRODUCT_LINE] starts with 'Golf' Result 1: Golf Equipment Example 2: [PRODUCT_LINE] starts with 'Outdoor%' Result 2: Outdoor Equipment Example 3: [PRODUCT_LINE] starts with literal 'Golf%' Result 3: Golf% Example 4: [PRODUCT_LINE] starts with 'Current_Year%' Result 4: Current Year Price, Current Year Price%, Current_Year Price% Example 5: [PRODUCT_LINE] starts with literal 'Current_Year%' Result 5: Current_Year% Works with the if or case constructs. When the if condition or the when expression are true, the then expression is used. This function appears in the Top 10 Retailers for 2005 sample report in the GO Data Warehouse (analysis) package. if ( condition ) then ..., or case expression when expression then .... end Works with the case construct. You can define conditions to occur when the WHEN expression is true. case [expression] when ... end
Summaries This list contains predefined functions that return either a single summary value for a group of related values or a different summary value for each instance of a group of related values. Returns a calculated value using the appropriate aggregation function, based on the aggregation type of the expression. This function appears in the Budget vs. Actual sample report in the GO Data Warehouse (analysis) package. aggregate ( expression [ auto ] ) aggregate ( expression for [ all|any ] expression { , expression } ) aggregate ( expression for report ) Returns the average value of selected data items. Distinct is an alternative expression that is compatible with earlier versions of the product. average ( [ distinct ] expression [ auto ] ) average ( [ distinct ] expression for [ all|any ] expression { , expression } ) average ( [ distinct ] expression for report ) Example: average ( Sales ) Result: Returns the average of all Sales values. Returns the number of selected data items excluding null values. Distinct is an alternative expression that is compatible with earlier versions of the product. All is supported in DQM mode only and it avoids the presumption of double counting a data item of a dimension table. count ( [ all | distinct ] expression [ auto ] ) count ( [ all | distinct ] expression for [ all|any ] expression { , expression } ) count ( [ all | distinct ] expression for report ) Example: count ( Sales ) Result: Returns the total number of entries under Sales. Returns the maximum value of selected data items. Distinct is an alternative expression that is compatible with earlier versions of the product. maximum ( [ distinct ] expression [ auto ] ) maximum ( [ distinct ] expression for [ all|any ] expression { , expression } ) maximum ( [ distinct ] expression for report ) Example: maximum ( Sales ) Result: Returns the maximum value out of all Sales values. Returns the median value of selected data items. median ( expression [ auto ] ) median ( expression for [ all|any ] expression { , expression } ) median ( expression for report ) Returns the minimum value of selected data items. Distinct is an alternative expression that is compatible with earlier versions of the product. minimum ( [ distinct ] expression [ auto ] ) minimum ( [ distinct ] expression for [ all|any ] expression { , expression } ) minimum ( [ distinct ] expression for report ) Example: minimum ( Sales ) Result: Returns the minimum value out of all Sales values. Returns a moving average by row for a specified set of values of over a specified number of rows. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. moving-average ( numeric_expression , numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) moving-average (  numeric_expression , numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: moving-average ( Qty , 3 ) Result: For each row, returns the quantity and a moving average of the current row and the preceding two rows. Qty Moving-Average (Qty, 3) ------ ------------------------------------ 200 200 700 450 400 433.3333 200 433.3333 200 266.6667 500 300.0000 Returns a moving total by row for a specified set of values over a specified number of rows. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. moving-total ( numeric_expression , numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) moving-total (  numeric_expression , numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: moving-total ( Qty , 3 ) Result: For each row, returns the quantity and a moving total of the current row and the preceding two rows. Qty Moving-Total (Qty, 3) ------ -------------------------------- 200 200 700 900 400 1300 200 1300 200 800 500 900 Returns the percent of the total value for selected data items. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. This function appears in the Percentage Calculation (by year) interactive sample report. percentage ( numeric_expression [ at expression  { , expression } ] [ <for-option> ] [ prefilter ] ) percentage (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: percentage ( Sales 98 ) Result: Returns the percentage of the total sales for 1998 that is attributed to each sales representative. Employee Sales 98 Percentage --------- --------- ------------- Gibbons 60646 7.11% Flertjan 62523 7.35% Cornel 22396 2.63% Returns a value, on a scale of one hundred, that indicates the percent of a distribution that is equal to or below the selected data items. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. percentile ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) percentile (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: percentile ( Sales 98 ) Result: For each row, returns the percentage of rows that are equal to or less than the quantity value of that row. Qty Percentile (Qty) ------ ----------------- 800 1 700 0.875 600 0.75 500 0.625 400 0.5 400 0.5 200 0.25 200 0.25 Returns the rank of a value within a range that you specify. It returns integers to represent any range of ranks, such as 1 (highest) to 100 (lowest). The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. quantile ( numeric_expression , numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) quantile (  numeric_expression , numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: quantile ( Qty , 4 ) Result: Returns the quantity, the rank of the quantity value, and the quantity values broken down into 4 quantile groups (quartiles). Qty Rank Quantile (Qty, 4) ------ ------- --------------- 800 1 1 700 2 1 600 3 2 500 4 2 400 5 3 400 5 3 200 7 4 200 7 4 Returns the rank of a value, represented as integers from 1 (highest) to 4 (lowest), relative to a group of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. quartile ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) quartile (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: quartile ( Qty ) Result: Returns the quantity and the quartile of the quantity value represented as integers from 1 (highest) to 4 (lowest). Qty Quartile (Qty) ------ --------------------- 450 1 400 1 350 2 300 2 250 3 200 3 150 4 100 4 Returns the rank value of selected data items. The sort order is optional; descending order (DESC) is assumed by default. If two or more rows tie, then there is a gap in the sequence of ranked values (also known as Olympic ranking). The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. Distinct is an alternative expression that is compatible with earlier versions of the product. Null values are ranked last. This function appears in the Top 10 Retailers for 2005 sample report in the GO Data Warehouse (analysis) package. rank ( expression [ ASC|DESC ] { , expression [ ASC|DESC ] } [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) rank ( [ distinct ] expression [ ASC|DESC ] { , expression [ ASC|DESC ] } [ <for-option>] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: rank ( Sales 98 ) Result: For each row, returns the rank value of sales for 1998 that is attributed to each sales representative. Some numbers are skipped when a tie between rows occurs. Employee Sales 98 Rank --------- --------- ------------ Gibbons 60000 1 Flertjan 50000 2 Cornel 50000 2 Smith 48000 4 Returns the running average by row (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. running-average ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-average (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: running-average ( Qty ) Result: For each row, returns the quantity and a running average of the current and the previous rows. Name Qty Avg Running-Average for name ------- ------ ------ ----------------------- Smith 7 5 7 Smith 3 5 5 Smith 6 5 5.33 Smith 4 5 5 Wong 3 4 3 Wong 5 4 4 Returns the running count by row (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. running-count ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-count (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: running-count ( Qty ) Result: For each row, returns the quantity and a running count of the position of the current row. Name Qty Count Running-Count for name ------- ------ --------- ------------------------ Smith 7 4 1 Smith 3 4 2 Smith 6 4 3 Smith 4 4 4 Wong 3 3 1 Wong 5 3 2 Returns a running difference by row, calculated as the difference between the value for the current row and the preceding row, (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. running-difference ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-difference (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: running-difference ( Qty ) Result: For each row, returns the quantity and a running difference between the value for the current row and the preceding row. Name Qty Running-Difference for name ------- ------ --------------------------- Smith 7 NULL Smith 3 -4 Smith 6 3 Smith 4 -2 Wong 3 -1 Wong 5 2 Returns the running maximum by row (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. running-maximum (  numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-maximum (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: running-maximum ( Qty ) Result: For each row, returns the quantity and a running maximum of the current and previous rows. Name Qty Max Running-Maximum (Qty) for name ------- ------ ------ ------------------------- Smith 2 7 2 Smith 3 7 3 Smith 6 7 6 Smith 7 7 7 Wong 3 5 3 Wong 5 5 5 Returns the running minimum by row (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. running-minimum ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-minimum (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: running-minimum ( Qty ) Result: For each row, returns the quantity and a running minimum of the current and previous rows. Name Qty Min Running-Minimum (Qty) for name ------- ----- ------ -------------------------- Smith 7 2 7 Smith 3 2 3 Smith 6 2 3 Smith 2 2 2 Wong 4 3 4 Wong 5 3 4 Returns a running total by row (including the current row) for a set of values. The "<for-option>" defines the scope of the function. The "at" option defines the level of aggregation and can be used only in the context of relational datasources. running-total ( numeric_expression [ at expression { , expression } ] [ <for-option> ] [ prefilter ] ) running-total (  numeric_expression [ <for-option> ] [ prefilter ] ) <for-option> ::= for expression { , expression }|for report|auto Example: running-total ( Qty ) Result: For each row, returns the quantity and a running total of the current and previous rows. Name Qty Total Running-Total (Qty) for name ------- ------ -------- ------------------------- Smith 2 18 2 Smith 3 18 5 Smith 6 18 11 Smith 7 18 18 Wong 3 12 3 Wong 5 12 8 Returns the standard deviation of selected data items. standard-deviation (  expression [ auto ] ) standard-deviation (  expression for [ all|any ] expression { , expression } ) standard-deviation (  expression for report ) Example: standard-deviation ( ProductCost ) Result: Returns a value indicating the deviation between product costs and the average product cost. Computes the population standard deviation and returns the square root of the population variance. standard-deviation-pop (  expression [ auto ] ) standard-deviation-pop (  expression for [ all|any ] expression { , expression } ) standard-deviation-pop (  expression for report ) Example: standard-deviation-pop ( ProductCost ) Result: Returns a value of the square root of the population variance. Computes the sample standard deviation and returns the square root of the population variance. standard-deviation-samp (  expression [ auto ] ) standard-deviation-samp (  expression for [ all|any ] expression { , expression } ) standard-deviation-samp (  expression for report ) Example: standard-deviation-samp ( ProductCost ) Result: Returns a value of the square root of the sample variance. Returns the rank of a value as High, Middle, or Low relative to a group of values. tertile (  expression [ auto ] ) tertile (  expression for [ all|any ] expression { , expression } ) tertile (  expression for report ) Example: tertile ( Qty ) Result: Returns the quantity, the quantile of the quantity value as broken down into tertiles, and the quantity values broken down into tertiles. Qty Quantile (Qty, 3) Tertile (Qty) ------ ------------------------ ------------------ 800 1 H 700 1 H 500 2 M 400 2 M 200 3 L 200 3 L Returns the total value of selected data items. Distinct is an alternative expression that is compatible with earlier versions of the product. This function appears in the Budget vs. Actual sample report in the GO Data Warehouse (analysis) package. total ( [ distinct ] expression [ auto ] ) total ( [ distinct ] expression for [ all|any ] expression { , expression } ) total ( [ distinct ] expression for report ) Example: total ( Sales ) Result: Returns the total value of all Sales values. Statistical functions This list contains predefined summary functions of statistical nature. Returns the variance of selected data items. variance (  expression [ auto ] ) variance (  expression for [ all|any ] expression { , expression } ) variance (  expression for report ) Example: variance ( Product Cost ) Result: Returns a value indicating how widely product costs vary from the average product cost. Returns the population variance of a set of numbers after discarding the nulls in this set. variance-pop (  expression [ auto ] ) variance-pop (  expression for [ all|any ] expression { , expression } ) variance-pop (  expression for report ) Example: variance-pop ( Qty ) Result: For each row, returns the population variance of a set of numbers after discarding the nulls in this set. Returns the sample variance of a set of numbers after discarding the nulls in this set. variance-samp (  expression [ auto ] ) variance-samp (  expression for [ all|any ] expression { , expression } ) variance-samp (  expression for report ) Example: variance-samp ( Qty ) Result: For each row, returns the sample variance of a set of numbers after discarding the nulls in this set. corr ( numeric_expression1 ,  numeric_expression2  [ auto ] ) corr ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) corr ( numeric_expression1 ,  numeric_expression2 for report ) Returns the coefficient of correlation of a set of number pairs. This is computed as follows: COVAR_POP(numeric_expression1, numeric_expression2) / (STDDEV_POP(numeric_expression1) * STDDEV_POP(numeric_expression2)) Example: corr ( Cost ,  Margin  for report) Result: The coefficient of correlation between Cost and Margin. Cost Margin corr (Cost, Margin for report) ------- ---------- ----------------------------------------- 4 0.33 0.0872648 5 0.28 0.0872648 9.22 0.23 0.0872648 15.93 0.28 0.0872648 34.97 0.3 0.0872648 covariance-pop ( numeric_expression1 ,  numeric_expression2 ) covariance-pop ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) covariance-pop ( numeric_expression1 ,  numeric_expression2 for report ) Returns the population covariance of a set of number pairs. Example: covariance-pop ( Cost ,  Margin  for report) Result: The population covariance between Cost and Margin. Cost Margin covariance-pop (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 0.032384 5 0.28 0.032384 9.22 0.23 0.032384 15.93 0.28 0.032384 34.97 0.3 0.032384 covariance-samp ( numeric_expression1 ,  numeric_expression2 ) covariance-samp ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) covariance-samp ( numeric_expression1 ,  numeric_expression2 for report ) Returns the sample covariance of a set of number pairs. Example: covariance-samp ( Cost ,  Margin  for report) Result: The sample covariance between Cost and Margin. Cost Margin covariance-samp (Cost, Margin for report) ------- ---------- ------------------------------------------------------------ 4 0.33 0.04048 5 0.28 0.04048 9.22 0.23 0.04048 15.93 0.28 0.04048 34.97 0.3 0.04048 regression-average-x ( numeric_expression1 ,  numeric_expression2 ) regression-average-x ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-average-x ( numeric_expression1 ,  numeric_expression2 for report ) Returns the average of the independent variable (numeric_expression2) of the regression line. Example: regression-average-x ( Cost ,  Margin  for report) Result: The average of Margin within the regression line for Cost and Margin. Cost Margin regression-average-x (Cost, Margin for report) ------- ---------- ----------------------------------------------------------------- 4 0.33 0.284 5 0.28 0.284 9.22 0.23 0.284 15.93 0.28 0.284 34.97 0.3 0.284 regression-average-y ( numeric_expression1 ,  numeric_expression2 ) regression-average-y ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-average-y ( numeric_expression1 ,  numeric_expression2 for report ) Returns the average of the dependent variable (numeric_expression1) of the regression line. Example: regression-average-y ( Cost ,  Margin  for report) Result: The average of Cost within the regression line for Cost and Margin. Cost Margin regression-average-y (Cost, Margin for report) ------- ---------- ----------------------------------------------------------------- 4 0.33 13.824 5 0.28 13.824 9.22 0.23 13.824 15.93 0.28 13.824 34.97 0.3 13.824 regression-count ( numeric_expression1 ,  numeric_expression2 ) regression-count ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-count ( numeric_expression1 ,  numeric_expression2 for report ) Returns the number of non-null numbers used to fit the regression line. Example: regression-count ( Cost ,  Margin  for report) Result: The number of non-null numbers used to fit the regression line for Cost and Margin. Cost Margin regression-count (Cost, Margin for report) ------- ---------- ----------------------------------------------------------- 4 0.33 5 5 0.28 5 9.22 0.23 5 15.93 0.28 5 34.97 0.3 5 regression-intercept ( numeric_expression1 ,  numeric_expression2 ) regression-intercept ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-intercept ( numeric_expression1 ,  numeric_expression2 for report ) Returns the y-intercept of the regression line. This is computed as follows: AVG(numeric_expression1) - REGR_SLOPE(numeric_expression1, numeric_expression2) * AVG(numeric_expression2) Example: regression-intercept ( Cost ,  Margin  for report) Result: The y-intercept of the regression line for Cost and Margin. Cost Margin regression-intercept (Cost, Margin for report) ------- ---------- ---------------------------------------------------------------- 4 0.33 5.18015038 5 0.28 5.18015038 9.22 0.23 5.18015038 15.93 0.28 5.18015038 34.97 0.3 5.18015038 regression-r2 ( numeric_expression1 ,  numeric_expression2 ) regression-r2 ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-r2 ( numeric_expression1 ,  numeric_expression2 for report ) Returns the coefficient of determination (also known as "R-squared" or "goodness of fit") of the regression line. This value is computed based on the following conditions: IF VAR_POP(numeric_expression2) = 0 THEN NULL IF VAR_POP(numeric_expression1) = 0 AND VAR_POP(numeric_expression2) <> 0 THEN 1 IF VAR_POP(numeric_expression1) > 0 and VAR_POP(numeric_expression2) <> 0 THEN POWER(CORR (numeric_expression1, numeric_expression2)) Example: regression-r2 ( Cost ,  Margin  for report) Result: The coefficient of determination of the regression line for Cost and Margin. Cost Margin regression-r2 (Cost, Margin for report) ------- ---------- ------------------------------------------------------ 4 0.33 0.00761514 5 0.28 0.00761514 9.22 0.23 0.00761514 15.93 0.28 0.00761514 34.97 0.3 0.00761514 regression-slope ( numeric_expression1 ,  numeric_expression2 ) regression-slope ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-slope ( numeric_expression1 ,  numeric_expression2 for report ) Returns the slope of the regression line. This is computed as follows: COVAR_POP(numeric_expression1,numeric_expression2) / VAR_POP(numeric_expression2) Example: regression-slope ( Cost ,  Margin ) Result: The slope of the regression line for Cost and Margin. Cost Margin regression-slope (Cost, Margin for report) ------- ---------- ----------------------------------------------------------- 4 0.33 30.43609023 5 0.28 30.43609023 9.22 0.23 30.43609023 15.93 0.28 30.43609023 34.97 0.3 30.43609023 regression-sxx ( numeric_expression1 ,  numeric_expression2 ) regression-sxx ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-sxx ( numeric_expression1 ,  numeric_expression2 for report ) Returns the following computation after eliminating NULL pairs: REGR_COUNT(numeric_expression1, numeric_expression2) * VAR_POP(numeric_expression2) Example: regression-sxx ( Cost ,  Margin  for report) Result: The sxx computation of the regression line for Cost and Margin. Cost Margin regression-sxx (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 0.00532 5 0.28 0.00532 9.22 0.23 0.00532 15.93 0.28 0.00532 34.97 0.3 0.00532 regression-sxy ( numeric_expression1 ,  numeric_expression2 ) regression-sxy ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-sxy ( numeric_expression1 ,  numeric_expression2 for report ) Returns the following computation after eliminating NULL pairs: REGR_COUNT(numeric_expression1, numeric_expression2) * COVAR_POP(numeric_expression1, numeric_expression2) Example: regression-sxy ( Cost ,  Margin  for report) Result: The sxy computation of the regression line for Cost and Margin. Cost Margin regression-sxy (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 0.16192 5 0.28 0.16192 9.22 0.23 0.16192 15.93 0.28 0.16192 34.97 0.3 0.16192 regression-syy ( numeric_expression1 ,  numeric_expression2 ) regression-syy ( numeric_expression1 ,  numeric_expression2 for [ all|any ] expression { , expression } ) regression-syy ( numeric_expression1 ,  numeric_expression2 for report ) Returns the following computation after eliminating NULL pairs: REGR_COUNT(numeric_expression1, numeric_expression2) * VAR_POP(numeric_expression1) Example: regression-syy ( Cost ,  Margin  for report) Result: The syy computation of the regression line for Cost and Margin. Cost Margin regression-syy (Cost, Margin for report) ------- ---------- --------------------------------------------------------- 4 0.33 647.15932 5 0.28 647.15932 9.22 0.23 647.15932 15.93 0.28 647.15932 34.97 0.3 647.15932 Member Summaries This list contains predefined functions that return either a single summary value for a set of members or a different summary value for each member in a set of members.
Error There is an error in your expression at the highlighted token.
Constructs This list contains constructs and templates that can be used to create an expression. Templates combine multiple functions into a group. For example, the search case template includes the case, when, else, and end functions. search case This construct is the template for a search case, including the CASE, WHEN, ELSE, and END functions. CASE WHEN [Country] = 'Canada' THEN ([List Price] * 0.60) WHEN [CountryCode] > 100 THEN [List Price] * 0.80 ELSE [List Price] END simple case This construct is the template for a simple case, including the CASE, WHEN, ELSE, and END functions. CASE [Country] WHEN 'Canada' THEN ([List Price] * 0.60) WHEN 'Australia' THEN [List Price] * 0.80 ELSE [List Price] END if then else This construct is the template for an if...then...else statement. This construct appears in the Top 10 Retailers for 2005 sample report in the GO Data Warehouse (analysis) package. IF ([Country] = 'Canada') THEN ([List Price] * 0.60) ELSE ([List Price]) in_range This is the template for an in_range expression. [code] IN_RANGE { :30 , 40, 50, 999: } Example: [code] IN_RANGE { 5 } Result: This is equivalent to [code] = 5. Example: [code] IN_RANGE { 5: } Result: This is equivalent to [code] >= 5. Example: [code] IN_RANGE { :5 } Result: This is equivalent to [code] <= 5. Example: [code] IN_RANGE { 5:10 } Result: This is equivalent to ( [code] >= 5 and [code] <= 10 ). Example: [code] IN_RANGE { :5,10,20: } Result: This is equivalent to ( [code] <= 5 or [code] = 10 or [code] >= 20 ).
Period Predicates This list contains predicates that can be used to compare period expressions. contains Returns "true" if "period_expression1" contains "period_expression2"; that is, "true" is returned if the first period contains the datetime value, or all the values, that are contained in the second period. period_expression1 contains ( period_expression2 | datetime_expression ) period( 1989-11-01, 1991-05-19 ) contains period( 1991-05-19, 1991-06-04 ) Result: false period( 1989-11-01, 1991-05-19 ) contains period( 1990-05-19, 1991-04-04 ) Result: true period( 1989-11-01, 1991-05-19 ) contains 1991-04-04 Result: true equals Returns "true" if "period_expression1" and "period_expression2" have the same period start and period end values. period_expression1 equals period_expression2 period( 1989-11-01, 1991-05-19 ) equals period( 1989-11-01, 1991-05-19 ) Result: true immediately precedes Returns "true" if "period_expression1" immediately precedes "period_expression2"; that is, the end value of the first period equals the start value of the second period. period_expression1 immediately precedes period_expression2 period( 1989-11-01, 1991-05-19 ) immediately precedes period( 1991-05-19, 1991-06-04 ) Result: true period( 1989-11-01, 1991-05-18 ) immediately precedes period( 1991-05-19, 1991-06-04 ) Result: false immediately succeeds Returns "true" if "period_expression1" immediately succeeds "period_expression2"; that is, the start value of the first period equals the end value of the second period. period_expression1 immediately succeeds period_expression2 period( 1991-05-19, 1994-01-10 ) immediately succeeds period( 1991-01-19, 1991-05-19 ) Result: true period( 1991-05-19, 1994-01-10 ) immediately succeeds period( 1991-01-20, 1991-05-18 ) Result: false overlaps Returns "true" if "period_expression1" overlaps "period_expression2"; that is, have at least one value in common. period_expression1 overlaps period_expression2 period( 1991-05-19, 1994-01-10 ) overlaps period( 1993-01-19, 1995-05-19 ) Result: true precedes Returns "true" if "period_expression1" precedes "period_expression2"; that is, all values contained in the first period are less than or equal to the start value of the second period. period_expression1 precedes period_expression2 period( 1989-11-01, 1991-05-19 ) precedes period( 1991-05-19, 1991-06-04 ) Result: true period( 1989-11-01, 1991-05-18 ) precedes period( 1991-05-19, 1991-06-04 ) Result: true succeeds Returns "true" if "period_expression1" succeeds "period_expression2"; that is, all values contained in the first period are greater than or equal to the end value of the second period. period_expression1 succeeds period_expression2 period( 1991-05-19, 1994-01-10 ) succeeds period( 1991-01-19, 1991-05-19 ) Result: true period( 1991-05-20, 1994-01-10 ) succeeds period( 1991-01-20, 1991-05-19 ) Result: true
Business Date/Time Functions This list contains business functions for performing date and time calculations. _add_seconds ( time_expression, integer_expression ) Returns the time or datetime, depending on the format of "time_expression", that results from adding "integer_expression" seconds to "time_expression". Example: _add_seconds ( 13:04:59 , 1 ) Result: 13:05:00 Example: _add_seconds ( 2002-04-30 12:10:10.000, 1 ) Result: 2002-04-30 12:10:11.000 Example: _add_seconds ( 2002-04-30 00:00:00.000, 1/100 ) Note that the second argument is not a whole number. This is supported by some database technologies and increments the time portion. Result: 2002-04-30 00:00:00.010 _add_minutes ( time_expression, integer_expression ) Returns the time or datetime, depending on the format of "time_expression", that results from adding "integer_expression" minutes to "time_expression". Example: _add_minutes ( 13:59:00 , 1 ) Result: 14:00:00 Example: _add_minutes ( 2002-04-30 12:59:10.000, 1 ) Result: 2002-04-30 13:00:10.000 Example: _add_minutes ( 2002-04-30 00:00:00.000, 1/60 ) Note that the second argument is not a whole number. This is supported by some database technologies and increments the time portion. Result: 2002-04-30 00:00:01.000 _add_hours ( time_expression, integer_expression ) Returns the time or datetime, depending on the format of "time_expression", that results from adding "integer_expression" hours to "time_expression". Example: _add_hours ( 13:59:00 , 1 ) Result: 14:59:00 Example: _add_hours ( 2002-04-30 12:10:10.000, 1 ) Result: 2002-04-30 13:10:10.000, Example: _add_hours ( 2002-04-30 00:00:00.000, 1/60 ) Note that the second argument is not a whole number. This is supported by some database technologies and increments the time portion. Result: 2002-04-30 00:01:00.000 _add_days ( date_expression, integer_expression ) Returns the date or datetime, depending on the format of "date_expression", that results from adding "integer_expression" days to "date_expression". Example: _add_days ( 2002-04-30 , 1 ) Result: 2002-05-01 Example: _add_days ( 2002-04-30 12:10:10.000, 1 ) Result: 2002-05-01 12:10:10.000 Example: _add_days ( 2002-04-30 00:00:00.000, 1/24 ) Note that the second argument is not a whole number. This is supported by some database technologies and increments the time portion. Result: 2002-04-30 01:00:00.000 _add_months ( date_expression, integer_expression ) Adds "integer_expression" months to "date_expression". If the resulting month has fewer days than the day of month component, then the last day of the resulting month is returned. In all other cases the returned value has the same day of month component as "date_expression". Example: _add_months ( 2012-04-15 , 3 ) Result: 2012-07-15 Result is not the last day of the resultant month. Example: _add_months ( 2012-02-29 , 1 ) Result: 2012-03-29 Use the function _last_of_month to return the last day of the month. Example: _last_of_month ( _add_months ( 2012-02-29 , 1 ) ) Result: 2012-03-31 Day is adjusted to the last day of the resulting month. Example: _add_months ( 2012-01-31 , 1 ) Result: 2012-02-29 Adding to a timestamp. Example: _add_months ( 2002-04-30 12:10:10.000 , 1 ) Result: 2002-05-30 12:10:10.000 _add_years ( date_expression, integer_expression ) Adds "integer_expression" years to "date_expression". If the "date_expression" is February 29 and resulting year is non leap year, then the resulting day is set to February 28. In all other cases the returned value has the same day and month as "date_expression". Example: _add_years ( 2012-04-15 , 1 ) Result: 2013-04-15 February 29 is adjusted for non leap years. Example: _add_years ( 2012-02-29 , 1 ) Result: 2013-02-28 Adding to a timestamp. Example: _add_years ( 2002-04-30 12:10:10.000 , 1 ) Result: 2003-04-30 12:10:10.000 _age ( date_expression ) Returns a number that is obtained from subtracting "date_expression" from today's date. The returned value has the form YYYYMMDD, where YYYY represents the number of years, MM represents the number of months, and DD represents the number of days. Example: _age ( 1990-04-30 ) (if today's date is 2003-02-05) Result: 120906, meaning 12 years, 9 months, and 6 days. _date_to_int ( date_expression ) Returns the integer representation of "date_expression", which can be of type "date", "timestamp" or "timestamp with time zone". The returned value has the form YYYYMMDD, where YYYY represents the number of years, MM represents the number of months, and DD represents the number of days. Example: _date_to_int ( 2003-01-01 ) Result: 20030101 Example: _date_to_int ( 2003-01-01 13:00:00.000 ) Result: 20030101 _day_of_week ( date_expression, integer ) Returns the day of week (1 to 7), where 1 is the first day of the week as indicated by the second parameter (1 to 7, 1 being Monday and 7 being Sunday). Note that in ISO 8601 standard, a week begins with Monday being day 1. Example: _day_of_week ( 2003-01-01 , 1 ) Result: 3 _day_of_year ( date_expression ) Returns the day of year (1 to 366) in "date_ expression". Also known as Julian day. Example: _day_of_year ( 2003-03-01 ) Result: 61 _days_between ( date_expression1 , date_expression2 ) Returns a positive or negative number representing the number of days between "date_expression1" and "date_expression2". If "date_expression1" < "date_expression2", then the result will be a negative number. Example: _days_between ( 2002-06-21 , 2002-04-30 ) Result: 52 Example: _days_between ( 2002-04-30 , 2002-06-21 ) Result: -52 _days_to_end_of_month ( date_expression ) Returns a number representing the number of days remaining in the month represented by "date_expression". Example: _days_to_end_of_month ( 2002-04-20 14:30:22.123 ) Result: 10 _first_of_month ( date_expression ) Returns a date or datetime, depending on the argument, by converting "date_expression" to a date with the same year and month but with the day set to 1. Example: _first_of_month ( 2002-04-20 ) Result: 2002-04-01 Example: _first_of_month ( 2002-04-20 12:10:10.000 ) Result: 2002-04-01 12:10:10.000 _last_of_month ( date_expression ) Returns a date or datetime, depending on the argument, that is the last day of the month represented by "date_expression". Example: _last_of_month ( 2002-01-14 ) Result: 2002-01-31 Example: _last_of_month ( 2002-01-14 12:10:10.000 ) Result: 2002-01-31 12:10:10.000 _make_timestamp ( integer_expression1, integer_expression2, integer_expression3 ) Returns a timestamp constructed from "integer_expression1" (the year), "integer_expression2" (the month), and "integer_expression3" (the day). The time portion defaults to 00:00:00.000 . Example: _make_timestamp ( 2002 , 01 , 14 ) Result: 2002-01-14 00:00:00.000 _months_between ( date_expression1, date_expression2 ) Returns a positive or negative integer number representing the number of months between "date_expression1" and "date_expression2". If "date_expression1" is earlier than "date_expression2", then a negative number is returned. Example: _months_between ( 2002-04-03 , 2002-01-30 ) Result: 2 Example: _months_between ( 2002-01-30 , 2002-04-03 ) Result: -2 _shift_timezone ( timestamp_value , from_time_zone , target_time_zone ) _shift_timezone ( timestamp_with_time_zone_value , target_time_zone ) Shifts a timestamp value from one time zone to another time zone. This function honors the Daylight Savings Time when applicable. If the first argument is of type "timestamp", then the second and third arguments represent the "from" and "target" time zones, respectively. If the first argument is of type "timestamp with time zone", then the "from" time zone is already implied in the first argument therefore the second argument represents the "target" time zone. The data type of the first argument will also determine the data type of the return value. The second and third arguments are of type "string" and represent time zone identifiers. A list of these identifiers can be found below. Note: using this function will cause local processing. Example: _shift_timezone( 2013-06-30 12:00:00 , 'America/New_York' , 'GMT' ) Result: 2013-06-30 16:00:00 Example: _shift_timezone( 2013-11-30 12:00:00-05:00 , 'America/Vancouver' ) Result: 2013-11-30 09:00:00-08:00 Time zone identifiers: GMT (GMT+00:00) Greenwich Mean Time Europe/Lisbon (GMT+00:00) Portugal Time (Lisbon) Europe/Amsterdam (GMT+01:00) Netherlands Time Europe/Paris (GMT+01:00) France Time Europe/Berlin (GMT+01:00) Germany Time Europe/Brussels (GMT+01:00) Belgium Time Europe/Rome (GMT+01:00) Italy Time Europe/Vienna (GMT+01:00) Austria Time Africa/Cairo (GMT+02:00) Egypt Time Africa/Johannesburg (GMT+02:00) South Africa Time Europe/Athens (GMT+02:00) Greece Time Africa/Addis_Ababa (GMT+03:00) Ethiopia Time Asia/Dubai (GMT+04:00) United Arab Emirates Time Asia/Karachi (GMT+05:00) Pakistan Time Asia/Calcutta (GMT+05:30) India Time Asia/Dhaka (GMT+06:00) Bangladesh Time Asia/Saigon (GMT+07:00) Vietnam Time Asia/Hong_Kong (GMT+08:00) Hong Kong SAR China Time Asia/Tokyo (GMT+09:00) Japan Time Australia/Darwin (GMT+09:30) Australia Time (Darwin) Australia/Sydney (GMT+10:00) Australia Time (Sydney) Pacific/Guadalcanal (GMT+11:00) Solomon Islands Time America/Argentina/San_Juan (GMT-03:00) Argentina Time (San Juan) America/Buenos_Aires (GMT-03:00) Argentina Time (Buenos Aires) America/Sao_Paulo (GMT-03:00) Brazil Time (Sao Paulo) America/St_Johns (GMT-03:30) Canada Time (St. John’s) America/Puerto_Rico (GMT-04:00) Puerto Rico Time America/New_York (GMT-05:00) United States Time (New York) America/Toronto (GMT-05:00) Canada Time (Toronto) America/Jamaica (GMT-05:00) Jamaica Time America/Chicago (GMT-06:00) United States Time (Chicago) America/Mexico_City (GMT-06:00) Mexico Time (Mexico City) America/Cambridge_Bay (GMT-07:00) Canada Time (Cambridge Bay) America/Edmonton (GMT-07:00) Canada Time (Edmonton) America/Yellowknife (GMT-07:00) Canada Time (Yellowknife) America/Denver (GMT-07:00) United States Time (Denver) America/Chihuahua (GMT-07:00) Mexico Time (Chihuahua) America/Los_Angeles (GMT-08:00) United States Time (Los Angeles) America/Tijuana (GMT-08:00) Mexico Time (Tijuana) America/Vancouver (GMT-08:00) Canada Time (Vancouver) America/Anchorage (GMT-09:00) United States Time (Anchorage) Pacific/Honolulu (GMT-10:00) United States Time (Honolulu) Pacific/Tahiti (GMT-10:00) French Polynesia Time (Tahiti) Pacific/Midway (GMT-11:00) U.S. Minor Outlying Islands Time (Midway) Pacific/Niue (GMT-11:00) Niue Time A customized time zone identifier may also be used, using the format GMT(+|-)HH:MM. For example, GMT-06:30 or GMT+02:00. _week_of_year ( date_expression ) Returns the number of the week of the year of "date_expression" according to the ISO 8601 standard. Week 1 of the year is the first week of the year to contain a Thursday, which is equivalent to the first week containing January 4th. A week starts on Monday (day 1) and ends on Sunday (day 7). Example: _week_of_year ( 2003-01-01 ) Result: 1 _years_between ( date_expression1, date_expression2 ) Returns a positive or negative integer number representing the number of years between "date_expression1" and "date_expression2". If "date_expression1" < "date_expression2" then a negative value is returned. Example: _years_between ( 2003-01-30 , 2001-04-03 ) Result: 1 Example: _years_between ( 2001-04-03 , 2003-01-30 ) Result: -1 _ymdint_between ( date_expression1 , date_expression2 ) Returns a number representing the difference between "date_expression1" and "date_expression2". The returned value has the form YYYYMMDD, where YYYY represents the number of years, MM represents the number of months, and DD represents the number of days. Example: _ymdint_between ( 1990-04-30 , 2003-02-05 ) Result: 120905, meaning 12 years, 9 months and 5 days. _year ( date_expression ) Returns the value of the year field in "date_expression". Example: _year ( 2003-03-01 ) Result: 2003 _month ( date_expression ) Returns the value of the month field in "date_expression". Example: _month ( 2003-03-01 ) Result: 3 _day ( date_expression ) Returns the value of the day field in "date_expression". Example: _day ( 2003-03-01 ) Result: 1 _hour ( date_expression ) Returns the value of the hour field in "date_expression". Example: _hour ( 2002-01-31 12:10:10.254 ) Result: 12 _minute ( date_expression ) Returns the value of the minute field in "date_expression". Example: _minute ( 2002-01-31 12:10:10.254 ) Result: 10 _second ( date_expression ) Returns the value of the second field in "date_expression". Example: _second ( 2002-01-31 12:10:10.254 ) Result: 10.254 _timezone_hour ( timestamp_with_time_zone_value ) _timezone_hour ( time_with_time_zone_value ) Returns the value of the timezone hour field in the expression. The expression must be of type "timestamp with time zone" or "time with time zone". Example: _timezone_hour ( 2002-01-31 12:10:10.254-05:30 ) Result: -5 _timezone_minute ( timestamp_with_time_zone_value ) _timezone_minute ( time_with_time_zone_value ) Returns the value of the timezone minute field in the expression. The expression must be of type "timestamp with time zone" or "time with time zone". Example: _timezone_minute ( 2002-01-31 12:10:10.254-05:30 ) Result: -30 _start_of_day ([ date_expression ]) Returns the start of "date_expression" or start of today as a timestamp Example: _start_of_day ( 2014-11-23 12:10:10.254 ) Result: 2014-11-23 00:00:00 Example: _start_of_day () Result: 2016-01-01 00:00:00 _end_of_day ([ date_expression ]) Returns the end of "date_expression" or end of today as a timestamp. Example: _end_of_day ( 2014-11-23 12:10:10.254 ) Result: 2014-11-23 23:59:59 Example: _end_of_day () Result: 2016-01-01 23:59:59 _unix_timestamp ( date_expression ) Returns the number of seconds since 1970-01-01 00:00:00-00 for the given "date_expression". Example: _unix_timestamp ( 2014-11-23 ) Result: 1416718800 _from_unixtime ( integer_expression ) Returns the unix time specified by "integer_expression" as a timestamp with time zone. Example: _from_unixtime (1417807335) Result: 2014-12-05 19:22:15+00:00
Macro Functions This list contains functions that can be used within a macro. A macro may contain one or more macro functions. A macro is delimited by a number sign (#) at the beginning and at the end. Everything between the number signs is treated as a macro expression and is executed at run time. For macro functions that accept expressions of datatype timestamp with time zone as arguments, the accepted format is 'yyyy-mm-dd hh:mm:ss[.ff]+hh:mm' where fractional seconds are optional and can be represented by 1 to 9 digits. In lieu of a space separating the date portion to the time portion, the character 'T' is also accepted. Also, in lieu of the time zone '+hh:mm', the character 'Z' is accepted and will be processed internally as '+00:00'. The macro functions that return expressions of datatype timestamp with time zone return 9 digits by default for their fractional seconds. The macro function timestampMask () can be used to trim the output if required. Returns the timestamp with time zone (as a string) that results from adding "integer_expression" number of seconds to "string_expression", where "string_expression" represents a timestamp with time zone. _add_seconds ( string_expression , integer_expression ) Example: # _add_seconds ( '2005-11-01 12:00:00.000-05:00' , -1 ) # Result: 2005-11-01 11:59:59.000-05:00 Example: # _add_seconds ( $current_timestamp , 1 ) # Result: 2005-11-01 12:00:01.000000000-05:00 Example: # timestampMask ( _add_seconds ( $current_timestamp , 1 ) , 'hh:mm:ss' ) # Result: 12:00:01 Returns the timestamp with time zone (as a string) that results from adding "integer_expression" number of minutes to "string_expression", where "string_expression" represents a timestamp with time zone. _add_minutes ( string_expression , integer_expression ) Example: # _add_minutes ( '2005-11-01 12:00:00.000-05:00' , -1 ) # Result: 2005-11-01 11:59:00.000-05:00 Example: # _add_minutes ( $current_timestamp , 1 ) # Result: 2005-11-01 12:01:00.000000000-05:00 Example: # timestampMask ( _add_minutes ( $current_timestamp , 1 ) , 'hh:mm:ss' ) # Result: 12:01:00 Returns the timestamp with time zone (as a string) that results from adding "integer_expression" number of hours to "string_expression", where "string_expression" represents a timestamp with time zone. _add_hours ( string_expression , integer_expression ) Example: # _add_hours ( '2005-11-01 12:00:00.000-05:00' , -1 ) # Result: 2005-11-01 13:00:00.000-05:00 Example: # _add_hours ( $current_timestamp , 1 ) # Result: 2005-11-01 13:00:00.000000000-05:00 Example: # timestampMask ( _add_hours ( $current_timestamp , 1 ) , 'hh:mm:ss' ) # Result: 13:00:00 Returns the timestamp with time zone (as a string) that results from adding "integer_expression" number of days to "string_expression", where "string_expression" represents a timestamp with time zone. When the first argument is a date, specified as a string with format: yyyy-mm-dd, then the return value is a string formatted as a date. _add_days ( string_expression , integer_expression ) Example: # _add_days ( '2005-11-01 12:00:00.000-05:00' , -1 ) # Result: 2005-10-31 12:00:00.000000000-05:00 Example: # _add_days ( $current_timestamp , 1 ) # Result: 2005-11-02 12:00:00.000000000-05:00 Example: # timestampMask ( _add_days ( $current_timestamp , 1 ) , 'yyyy-mm-dd' ) # Result: 2005-11-02 Example: # _add_days( '2019-11-14' , 3 ) # Result: 2019-11-17 Returns the timestamp with time zone (as a string) that results from adding "integer_expression" number of months to "string_expression", where "string_expression" represents a timestamp with time zone. When the first argument is a date, specified as a string with format: yyyy-mm-dd, then the return value is a string formatted as a date. _add_months ( string_expression , integer_expression ) Example: # _add_months ( '2005-11-01 12:00:00.000-05:00' , -1 ) # Result: 2005-10-01 12:00:00.000000000-05:00 Example: # _add_months ( $current_timestamp , 1 ) # Result: 2005-12-01 12:00:00.000000000-05:00 Example: # timestampMask ( _add_months ( $current_timestamp , 1 ) , 'yyyy-mm-dd' ) # Result: 2005-12-01 Example: # _add_months( '2019-11-14' , -1 ) # Result: 2019-10-14 Returns the timestamp with time zone (as a string) that results from adding "integer_expression" number of years to "string_expression", where "string_expression" represents a timestamp with time zone. When the first argument is a date, specified as a string with format: yyyy-mm-dd, then the return value is a string formatted as a date. _add_years ( string_expression , integer_expression ) Example: # _add_years ( '2005-11-01 12:00:00.000-05:00' , -1 ) # Result: 2004-11-01 12:00:00.000000000-05:00 Example: # _add_years ( $current_timestamp , 1 ) # Result: 2006-11-01 12:00:00.000000000-05:00 Example: # timestampMask ( _add_years ( $current_timestamp , 1 ) , 'yyyy-mm-dd' ) # Result: 2006-11-01 Example: # _add_years( '2019-11-14' , -2 ) # Result: 2017-11-14 _first_of_month ( string_expression ) Returns a timestamp with time zone (as a string) by converting the day value in "string_expression" to 1, where "string_expression" is a timestamp with time zone. Example: # _first_of_month ( '2005-11-11 12:00:00.000-05:00' ) # Result: 2005-11-01 12:00:00.000000000-05:00 Example: # timestampMask ( _first_of_month ( '2005-11-11 12:00:00.000-05:00' ) , 'yyyymmdd' ) # Result: 20051101 _last_of_month ( string_expression ) Returns a timestamp with time zone (as a string) that is the last day of the month represented by "string_expression", where "string_expression" is a timestamp with time zone. Example: # _last_of_month ( '2005-11-11 12:00:00.000-05:00' ) # Result: 2005-11-30 12:00:00.000000000-05:00 Example: # timestampMask ( _last_of_month ( '2005-11-11 12:00:00.000-05:00' ) , 'yyyy-mm-dd' ) # Result: 2005-11-30 modelj ( 'identifier' [ , 'model_search_path' [ , 'options' ] ] ) Returns a portion of the metadata model in json format. The current model will be used when the 'model_search_path' is not specified. The 'options' argument can be set to 'cleanup', this changes some parts of the result to fixed values (useful for testing). sq ( modelj ( '[gosales].[country].[country]' ) Surrounds "string_expression" with square brackets. sb ( string_expression ) Example: # sb ( 'abc' ) # Result: [abc] Surrounds "string_expression" with single quotes. sq ( string_expression ) Example: # sq ( 'zero' ) # Result: 'zero' Surrounds "string_expression" with double quotes. dq ( string_expression ) Example: # dq ( 'zero' ) # Result: "zero" Uses the identity information of the current authenticated user to look up values in the specified parameter map. Each individual piece of the user's identity (account name, group names, role names) is used as a key into the map. The unique list of values that is retrieved from the parameter map is then returned as a string, where each value is surrounded by single quotes and where multiple values are separated by commas. CSVIdentityName ( %parameter_map_name [ , separator_string ] ) Example: # CSVIdentityName ( %security_clearance_level_map ) # Result: 'level_500', 'level_501', 'level_700' Returns the pieces of the user's identity (account name, group names, role names) as a list of strings. The unique list of values is returned as a string, where each value is surrounded by single quotes and where multiple values are separated by commas. CSVIdentityNameList ( [ separator_string ] ) Example: # CSVIdentityNameList ( ) # Result: 'Everyone', 'Report Administrators', 'Query User' Returns the Cognos® Access Manager passport. CAMPassport ( ) Example: # CAMPassport ( ) # Result: 111:98812d62-4fd4-037b-4354-26414cf7ebef:3677162321 Returns the pieces of the user's Cognos® Access Manager ID (CAMID), such as account name, group names, or role names, as a list of values separated by commas. CAMIDList ( [ separator_string ] ) Example: #CAMIDList ( ) # Result: CAMID ( "::Everyone" ) , CAMID ( ":Authors" ) , CAMID ( ":Query Users" ) , CAMID ( ":Consumers" ) , CAMID ( ":Metrics Authors" ) Returns an array of the user's Cognos® Access Manager IDs (CAMIDs) based on the identity type (account, group, or role). CAMIDListForType can be used with the macro functions csv or join. CAMIDListForType ( identity type ) Example: [qs].[userRole] in ( # csv ( CAMIDListForType ( 'role' ) ) # ) Result: [qs].[userRole] in ( 'CAMID ( "::System Administrators" ) ' , 'CAMID ( ":Authors" )' ) Concatenates two strings. value1 + value2 Example: # '{ ' + $runLocale + ' }' # Result: {en-us} Strips the leading characters from the first argument. The optional second argument defines the set of characters to strip. By default, this function strips white space (ie. space, tab, carriage return and line feed). lstrip ( string_expression [ , set_of_characters ] ) Example: # sq( lstrip ( ' abc ' ) ) # Result: 'abc ' Example: # lstrip ( ' 0053.2100 ' , '0 \t\r\n' ) # Result: 53.2100 Returns the parameter value of "parameterName" if it is defined. The value of "defaultText" will be returned if "parameterName" does not exist. When "datatype" is set to "string" then the result value will be surrounded by single quotes. The use of this function will not cause a missing parameter exception. ParamValue ( parameterName [ , defaultText [, datatype ] ] ) Example: # ParamValue ( 'p_country' ) # Result: 'Canada' - p_country is set Result: null - p_country is not a known parameter Result: null - p_country is used in an optional prompt and is not set Example: # ParamValue ( 'p_country' , 'Netherlands' ) # Result: 'Canada' - p_country is set Result: 'Netherlands' - p_country is not a known parameter Result: 'Netherlands' - p_country is used in an optional prompt and is not set Example: # ParamValue ( 'p_country', ' cast ( null as varchar(20)) ' , 'token' ) # Result: 'Canada' - p_country is set Result: cast ( null as varchar(20)) - p_country is not a known parameter Result: cast ( null as varchar(20)) - p_country is used in an optional prompt and is not set Prompts the user for a single value or member. Only "prompt_name" is required. The datatype defaults to 'string' when it is not specified. The prompt is optional when "defaultText" is specified. "Text", when specified, will precede the value. "QueryItem" can be specified to take advantage of the prompt information properties of "queryItem". "Trailing_text", when specified, will be appended to the value. When the data type is 'memberuniquename', a single select member prompt is created. It is good practice to provide a default value, as 3rd argument. The default value must be a valid member unique name; it can also be an alias that references a member unique name as done in Report Studio. prompt ( prompt_name , datatype , defaultText , text , queryItem , trailing_text ) Example: select . . . where COUNTRY_MULTILINGUAL.COUNTRY_CODE > #prompt ( 'Starting CountryCode' , 'integer' , '10' ) # Result: select . . . where COUNTRY_MULTILINGUAL.COUNTRY_CODE > 10 Example: [gosales].[COUNTRY].[COUNTRY] = # prompt ( 'countryPrompt' , 'string' , '''Canada''' ) # Result: [gosales].[COUNTRY].[COUNTRY] = 'Canada' Example: set ( #prompt ('myProduct', 'memberuniquename', '[Camping Equipment]', '', '[Sales].[Product].[Product].[Product line]')#) Result: set([Sales].[Product].[Product].[Product line]->[all].[1]) The "defaultText" parameter must be specified such that it is literally valid in the context of the macro since no formatting takes place on this value. The default string '''Canada''' in Example 2 is specified as a string using single quotes, in which the embedded single quotes are doubled up, thus 3 quotes. This results in the string being properly displayed within single quotes in the expression. As a general rule for the string datatype, "defaultText" should always be specified like this, except in the context of a stored procedure parameter. For "defaultText" of types 'date' or 'datetime', a special format should be used in the context of SQL. Examples of these formats are 'DATE ''2001-12-25''' and 'DATETIME ''2001-12-25 12:00:00'''. In all other contexts, use the date/datetime without the keyword and escaped single quotes (e.g., '2001-12-25'). Prompts the user for one or more values or members. Only "prompt_name" is required. The datatype defaults to 'string' when it is not specified. The prompt is optional when "defaultText" is specified. "Text", when specified, will precede the list of values. "QueryItem" can be specified to take advantage of the prompt information properties of "queryItem". "Trailing_text", when specified, will be appended to the list of values. When the data type is 'memberuniquename', a multi select member prompt is created. It is good practice to provide a default value, as 3rd argument. The default value must be a valid member unique name; it can also be an alias that references a member unique name as done in Report Studio. promptmany ( prompt_name , datatype , defaultText , text , queryItem , trailing_text ) Example: select . . . where COUNTRY_MULTILINGUAL.COUNTRY in ( # promptmany ( 'CountryName' ) # ) Result: select . . . where COUNTRY_MULTILINGUAL.COUNTRY_CODE in ( 'Canada' , 'The Netherlands' , 'Russia' ) Example: select . . . from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL , gosales.gosales.dbo.COUNTRY XX where COUNTRY_MULTILINGUAL.COUNTRY_CODE = XX.COUNTRY_CODE # promptmany ( 'Selected CountryCodes' , 'integer' , ' ' , ' and COUNTRY_MULTILINGUAL.COUNTRY_CODE in ( ' , '' , ' ) ' ) # Result: select . . . from gosales.gosales.dbo.COUNTRY_MULTILINGUAL COUNTRY_MULTILINGUAL , gosales.gosales.dbo.COUNTRY XX where COUNTRY_MULTILINGUAL.COUNTRY_CODE = XX.COUNTRY_CODE and COUNTRY_MULTILINGUAL.COUNTRY_CODE in ( 'Canada' , 'The Netherlands' , 'Russia' ) Example: set ( #promptmany ('myProduct', 'memberuniquename', '[Camping Equipment]', '', '[Sales].[Product].[Product].[Product line]')#) Result: set([Sales].[Product].[Product].[Product line]->[all].[1]; [Sales].[Product].[Product].[Product line]->[all].[2]) Execute a query for a single column and return the value in the first (only) row. The result is not formatted, make sure to surround the call with sq ( ) as needed. queryValue ( value_expression [ , filter_expression ] ) Example: # sq ( queryValue ( 'TheCalendar.TheWeekdayName' , 'TheCalendar.TheDate = 2018-06-06' ) ) # Result: 'Wednesday' Constructs an array out of the list of parameters. array ( string_expression|array_expression { , string_expression|array_expression } ) Example: # csv ( array ( 'a1' , array ( 'x1' , 'x2' ) , 'a2' ) ) # Result: 'a1' , 'x1' , 'x2' , 'a2' Constructs a string from the elements of the array where the values are separated by commas. Optionally, the separator and quote strings can be specified. The default separator is a comma ( , ) and the default quote character is a single quote ( ' ). csv ( array_expression [ , separator_string [ , quote_string ] ] ) Example: # sq ( csv ( array ( 'a1' , 'a2' ) ) ) # Result: 'a1', 'a2' Get an entry from the IBM® Cognos® configuration file. The force_decode_flag is optional and must be one of: 'true' , '1', 1 , 'false', '0', 0. The default is 'false'. In exceptional cases the force_decode_flag should be set to true. When the force_decode_flag is set to true then for entries configured in the IBM® Cognos® configuration via Advanced properties the plain text value of the configuration entry will be returned. For entries that are not identified in the Advanced properties an empty string is returned, irrespective of the presence of encrypted information. The entry in the Advanced properties is qs.getConfigurationEntry.1 and is a semi-colon separated list of names, by default this list of names is empty and calls to this function with the flag set to true will return an empty string. getConfigurationEntry ( entry_string , force_decode_flag ) Example: # getConfigurationEntry ( 'serverLocale'  ) # Result: en Returns an entry from a resource file. The first argument is the resource ID found in the resource file. The optional second argument is the resource file name without the locale suffix (e.g. 'mfwa4j' for the message file 'mfwa4j_en.properties'). The default resource file is 'xqejavamsgs'. The optional third argument is the locale, which defaults to 'en'. getResourceString ( resource_id_string [, resource_file_string [ , locale_string ] ] ) Example: # getResourceString ( 'XQE_BIN_binLow' ) # Result: XQE-BIN-0001 less than %1 Example: # getResourceString ( 'MFW_UT_INTERNAL_ERROR' , 'mfw4j' , 'en' ) # Result: MFW-UT-1002 An internal problem has occurred. Please contact your system administrator. Searches for and returns elements of an array that match the pattern specified in "pattern_string". The only supported metacharacters are: ^ (beginning of word), $ (end of word), ! (negate - only supported as the first character). grep ( pattern_string , array_expression ) Example: # sq ( csv ( grep ( 's' , array ( 'as', 'an', 'arts' ) ) ) ) # Result: 'as', 'arts' Example: # sq ( csv ( grep ( '^g' , array ( 'group', 'golf' ) ) ) ) # Result: 'group', 'golf' Example: # sq ( csv ( grep ( 's$' , array ( 'oranges', 'mangoes' ) ) ) ) # Result: 'oranges', 'mangoes' Example: # sq ( csv ( grep ( '!o' , array ( 'oranges', 'apples' ) ) ) ) # Result: 'apples' Find the offset in 'str' where 'substr' is found. The value -1 is returned when 'substr' is not found. You can also give an optional 'offset' to start the search at. The first argument 'str' can also be an array_expression, in that case the function is applied to each array element and the function result is an array of values. index ( str , substr [ , offset ] ) # index ( 'The black horse jumped over the black sheep.', 'black' ) # Result: 4 # index ( 'The black horse jumped over the black sheep.', 'black', 10 ) # Result: 32 # index ( 'The black horse jumped over the black sheep.', 'green' ) # Result: -1 # sq ( join ( ' | ', index ( array ('black' , 'red', 'green' ) , 'e' ) ) ) # Result: -1 | 1 | 2 Joins the elements of an array using "separator_string". join ( separator_string , array_expression ) Example: # sq ( join ( ' | | ' , array ( 'as', 'an', 'arts' ) ) ) # Result: 'as | | an | | arts' Computes the number of characters in string_expression. If the argument is an array_expression then the result will be an array of values, each entry will be the number of characters in each of array_expression elements. length ( string_expression | array_expression ) length ( 'abcdef' ) Result: 6 join ( '--', length ( array ( 'abcdef' , 'xyz' ) ) ) Result: 6--3 Find the last offset in 'str' where 'substr' is found. This function is called reverse index, you can view it as if it starts the scan from the end of the string. The value -1 is returned when 'substr' is not found. You can also give an optional 'offset' to end the search at. The first argument 'str' can be an array_expression, in that case the function is applied to each array element and the function result is an array of values. rindex ( str , substr [ , offset ] ) # rindex ( 'The black horse jumped over the black sheep.', 'black' ) # Result: 32 # rindex ( 'The black horse jumped over the black sheep.', 'black', 10 ) # Result: 4 # rindex ( 'The black horse jumped over the black sheep.', 'green' ) # Result: -1 # sq ( join ( ' | ', rindex ( array ('black' , 'red', 'green' ) , 'e' ) ) ) # Result: -1 | 1 | 3 Strips the trailing characters from the first argument. The optional second argument defines the set of characters to strip. By default, this function strips white space (ie. space, tab, carriage return and line feed). rstrip ( string_expression [ , set_of_characters ] ) Example: # sq( rstrip ( ' abc ' ) ) # Result: ' abc' Example: # rstrip ( ' 0053.2100 ' , '0 \t\r\n' ) # Result: 0053.21 Sorts the elements of the array in alphabetical order. Duplicates are retained. sort ( array_expression ) Example: # csv ( sort ( array ( 's3', 'a', 'x' ) ) ) # Result: 'a', 's3', 'x' Splits a string or string elements of the array into separate elements. split ( pattern_string, string_expression | array_expression ) Example: # sq ( csv ( split ( '::', 'ab=c::de=f::gh=i' ) ) ) # Result: 'ab=c', 'de=f', 'gh=i' Example: # sq ( csv ( split ( '=' , split ( '::', 'ab=c::de=f::gh=i' ) ) ) ) # Result: 'ab', 'c', 'de', 'f', 'gh', 'i' Strips the leading and trailing characters from the first argument. The optional second argument defines the set of characters to strip. By default, this function strips white space (ie. space, tab, carriage return and line feed). strip ( string_expression [ , set_of_characters ] ) Example: # sq( strip ( ' abc ' ) ) # Result: 'abc' Example: # strip ( ' 0053.2100 ' , '0 \t\r\n' ) # Result: 53.21 Searches for a pattern in a string or in the string elements of an array and substitutes the first occurrence of "pattern_string" with "replacement_string". The only supported metacharacters are: ^ (beginning of word), $ (end of word) substitute ( pattern_string, replacement_string, string_expression|array_expression ) Example: #sq ( substitute ( '^cn=', '***', 'cn=help' ) )# Result: '***help' Example: # csv ( substitute ( '^cn=', '***', array ( 'cn=help' , 'acn=5' ) ) ) # Result: '***help', 'acn=5' Example: # csv ( substitute ( 'cn=', '', array ( 'cn=help' , 'acn=5' ) ) ) # Result: 'help', 'a5' Example: #sq ( substitute ( 'help$', '***', 'cn=help' ) )# Result: 'cn=***' Extracts a part from 'string_expression' starting at 'start_offset'. You can specify that 'length' number of characters are to be extracted. If 'length' is not specified then up to the end of 'string_expression' is returned. The first argument can also be an array_expression, in that case the function is applied to each array element and the function result is an array of strings. substr ( string_expression , start_offset [ , length ] ) substr ( 'The horse is black.', 0, 3 ) Result: The substr ( 'The horse is black.', 4 ) Result: horse is black. substr ( 'The horse is black', index ('The horse is black.' , 'green' ) ) Result: The horse is black. join ( ' | ', substr ( array ('black' , 'red', 'green' ) , 2, 2 ) ) Result: ac | d | en substr ('over the moon', -2, 4) Results in an error: The second argument of function 'substr' must be larger or equal to -1.' . Returns "string_expression1", representing a timestamp with time zone, trimmed to the format specified in "string_expression2". The format in "string_expression2" must be one of the following: 'yyyy', 'mm', 'dd', 'yyyy-mm', 'yyyymm', 'yyyy-mm-dd', 'yyyymmdd', 'yyyy-mm-dd hh:mm:ss', 'yyyy-mm-dd hh:mm:ss+hh:mm', 'yyyy-mm-dd hh:mm:ss.ff3', 'yyyy-mm-dd hh:mm:ss.ff3+hh:mm', 'yyyy-mm-ddThh:mm:ss', 'yyyy-mm-ddThh:mm:ss+hh:mm', 'yyyy-mm-ddThh:mm:ss.ff3+hh:mm', or 'yyyy-mm-ddThh:mm:ss.ff3+hh:mm'. The macro functions that return a string representation of a timestamp with time zone show a precision of 9 digits for the fractional part of the seconds by default. The format options allow this to be trimmed down to a precision of 3 or 0. timestampMask ( string_expression1 , string_expression2 ) Example: # timestampMask ( $current_timestamp , 'yyyy-dd-mm' ) # Result: 2005-11-01 Example: # timestampMask (  '2005-11-01 12:00:00.000-05:00' , 'yyyy-mm-dd hh:mm:ss+hh:mm' ) # Result: 2005-11-01 12:00:00-05:00 Example: # timestampMask (  '2005-11-01 12:00:00.123456789-05:00' , 'yyyy-mm-ddThh:mm:ss+hh:mm.ff3+hh:mm' ) # Result: 2005-11-01T12:00:00.123-05:00 Returns the string representing a timestamp with time zone resulting from adjusting "string_expression" to the time zone of the operating system. Note that the macro function timestampMask () can be used to trim the output. toLocal ( string_expression ) Example: # toLocal ( '2005-11-01 17:00:00.000-00:00' ) # where OS local time zone is -05:00 Result: 2005-11-01 12:00:00.000000000-05:00 Example: # timestampMask ( toLocal ( '2005-11-01 17:00:00.000-00:00' ) , 'yyyy-mm-dd hh:mm:ss+hh:mm' ) # where OS local time zone is -05:00 Result: 2005-11-01 12:00:00-05:00 Example: # toLocal ( '2005-11-01 13:30:00.000-03:30' ) # where OS local time zone is -05:00 Result: 2005-11-01 12:00:00.000000000-05:00 Returns the string "string_expression" with all the characters converted to lower case using the rules of the locale "locale_string". If no locale is specified, the locale 'en' is used. tolower ( string_expression [ , locale_string ] ) Example: # tolower ( 'ABC' ) # Result: abc Example: # tolower ( 'ABC' , 'fr' ) # Result: abc Returns the string "string_expression" with all the characters converted to upper case using the rules of the locale defined in "locale_string". If "locale_string" is not specified, the locale 'en' is used. toupper ( string_expression [ , locale_string ] ) Example: # toupper ( 'abc' ) # Result: ABC Example: # toupper ( 'abc' , 'fr' ) # Result: ABC Returns the string representing a timestamp with time zone resulting from adjusting "string_expression" to the zero-point reference UTC time zone, also known as GMT time. Note that the macro function timestampMask () can be used to trim the output. toUTC ( string_expression ) Example: # toUTC ( '2005-11-01 12:00:00.000-05:00' ) # Result: 2005-11-01 17:00:00.000000000-00:00 Example: # timestampMask( toUTC ( '2005-11-01 12:00:00.000-05:00' ) , 'yyyy-mm-dd hh:mm:ss.ff3+hh:mm' ) # Result: 2005-11-01 17:00:00.000-00:00 Example: # toUTC ( $current_timestamp ) # Result: 2005-11-01 17:00:00.000000000-00:00 Removes duplicate entries from the array. The order of the elements is retained. unique ( array_expression ) # csv ( unique ( array ( 's3', 'a', 's3', 'x' ) ) ) # Result: 's3', 'a', 'x' URL-encodes the passed argument. This function is useful when specifying XML connection strings. urlencode ( prompt ( 'userValue' ) ) urlencode ( prompt ( 'some_val' ) ) %27testValue%27 simple case This macro construct is the template for a simple case, including the case, when, then, else, and end functions. Note that this macro construct is only supported in DQM mode. CASE <expression> WHEN <literal> THEN <expression> [ELSE <expression>] END Example: #CASE prompt('pDateRange','token') WHEN 'Current Week' THEN '[PR Current Week]' ELSE '[PR Prior Week]' END# Result: [PR Current Week]
Block Functions This list contains functions used to access members of a set, usually in the context of Analysis Studio. Returns the first members found in the set up to "numeric_expression_maximum" + "numeric_expression_overflow". If "numeric_expression_maximum" + "numeric_expression_overflow" is exceeded, then only the maximum number of members are returned. For a set that has only a few members more than the specified numeric_expression_maximum, the numeric_expression_overflow allows the small set of extra members to be included. If the set has more members than the overflow allows, then only the numeric_expression_maximum members will be returned. _firstFromSet ( set_expression , numeric_expression_maximum , numeric_expression_overflow ) _firstFromSet ( [great_outdoors_company].[Products].[Products].[Product line] , 2 , 8 ) Result: Returns the five members in the Product line set. The first two members are returned within the maximum and the following three members are returned as the overflow. Camping Equipment Golf Equipment Mountaineering Equipment Outdoor Protection Personal Accessories _firstFromSet ( [great_outdoors_company].[Products].[Products].[Product line] , 2 , 2 ) Result: Camping Equipment, Golf Equipment Returns the set containing "member_expression" when the size of "set_expression" is greater than "numeric_expression"; i.e., a new member will be generated if the number of members in "set_expression" is larger than the specified "numeric_expression". _remainderSet ( member_expression, set_expression , numeric_expression ) _remainderSet ( member ( aggregate ( currentMeasure within set [great_outdoors_company].[Products].[Products].[Product line] ) , 'Product Aggregate' , 'Product Aggregate' , [great_outdoors_company].[Products].[Products] ) , [great_outdoors_company].[Products].[Products].[Product line] , 1 ) Result: Quantity sold for Product Aggregate