### Get Day of Week Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the day of the week according to ISO 8601 (Monday=1, Sunday=7). An optional 'firstday' parameter can specify a different start of the week. ```sql DAYOFWEEK(#2018-07-12#) = 4 DAYOFWEEK(#2018-07-12#, "Sunday") = 5 ``` -------------------------------- ### Combine Segments in a Pie Chart Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/visualization-ref/pie-chart.md This example demonstrates how to combine multiple small segments into a larger 'Other' group using a CASE statement in a calculated field. Drag the new field to the Color section and the Sales field to Measures and Signatures. ```Python CASE [ProductSubcategory] WHEN "Beauty and health equipment" THEN "Beauty and health equipment" WHEN "Kitchen" THEN "Kitchen" WHEN "Kitchenware" THEN "Kitchenware" ELSE "Other" END ``` -------------------------------- ### Get Day of Month Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the day of the month from a specified date. ```sql DAY(#2018-07-12#) = 12 ``` -------------------------------- ### Format Indicator Text Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/visualization-ref/indicator-chart.md Use markup functions to format text, including bolding, sizing, and coloring, for indicator charts. This example shows how to display payment by card information. ```markdown BOLD(SIZE('Payment by card: ', '18px')) + BR() + BR() + SIZE(COLOR(STR(COUNTD_IF([OrderID], [PaymentType]='Bank card')),'blue') + ' / ' + STR(COUNTD([OrderID])), '26px') + BR() + BR() + SIZE(STR(ROUND(COUNTD_IF([OrderID], [PaymentType]='Bank card')/COUNTD([OrderID])*100, 2)) + ' % in total', '20px') ``` -------------------------------- ### Display Multiple Measures in Indicator Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/visualization-ref/indicator-chart.md Combine and format multiple measures within a single indicator using markup functions. This example displays counts of categories, subcategories, brands, and products. ```markdown SIZE('Amount: ', '18px') + BR() + BR() + COLOR(SIZE('- categories: ' + STR(COUNTD([ProductCategory])), '18px'), '#BE2443') + BR() + COLOR(SIZE('- subcategories: ' + STR(COUNTD([ProductSubcategory])), '18px'), 'blue') + BR() + COLOR(SIZE('- brands: ' + STR(COUNTD([ProductBrend])), '18px'), 'green') + BR() + COLOR(SIZE('- products: ' + STR(COUNTD([ProductName])), '18px'), '#FF7E00') ``` -------------------------------- ### Indicator with Images and Measures Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/visualization-ref/indicator-chart.md Embed images within an indicator chart and display associated measures. This example shows usage data for DataLens, Power BI, and Tableau, each with a logo. ```markdown IMAGE('https://storage.yandexcloud.net/dl--********//datalens.jpg', 32, 32, 'alt-text-1') + COLOR(SIZE('| ' + STR(SUM_IF([Usage],[Service]='DataLens')), '32px'), '#AEC5F3') + BR()+ COLOR(SIZE('DataLens', '20px'), '#AEC5F3')+ BR()+ BR()+ IMAGE('https://storage.yandexcloud.net/dl--********//powerbi.jpg', 32, 32, 'alt-text-1') + " " + COLOR(SIZE('| ' + STR(SUM_IF([Usage],[Service]='Power BI')), '32px'), '#B8A754')+ BR()+ COLOR(SIZE('Power BI', '20px'), '#B8A754')+ BR()+ BR()+ IMAGE('https://storage.yandexcloud.net/dl-********/tableu.jpg', 32, 32, 'alt-text-1') + " " + COLOR(SIZE('| ' + STR(SUM_IF([Usage],[Service]='Tableau')), '32px'), '#4D5DAB')+ BR()+ COLOR(SIZE('Tableau', '20px'), '#4D5DAB') ``` -------------------------------- ### Truncate DateTime Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Rounds a datetime down to a specified unit or a multiple of a unit. Supported units include second, minute, hour, day, week, month, quarter, and year. For 'month' unit, rounding starts from 1900-01-01. ```sql DATETRUNC(#2018-07-12 11:07:13#, "month", 4) = #2018-05-01 00:00:00# ``` -------------------------------- ### LIKE Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Performs pattern matching on strings. It returns TRUE if a string matches a specified pattern, and FALSE otherwise. The '%' character can be used as a wildcard. ```APIDOC ## LIKE ### Description Matches the string `string_1` to the template `string_2` and returns `TRUE` on match. You can specify the value in `string_2` or use the `%` character to match a string of any length. The `string_1 NOT LIKE` option returns the opposite value. When comparing values, the function is case-sensitive. You can use `LIKE` along with [UPPER](UPPER.md) or [LOWER](LOWER.md) for case-insensitive comparison. ### Syntax `string_1 [ NOT ] LIKE string_2` ``` -------------------------------- ### FIRST Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Retrieves the value from the first row within a specified window. ```APIDOC ## FIRST (window) ### Description Returns the value of `value` from the first row in the window. See also [LAST](LAST.md). ### Syntax `FIRST( value )`
or
`FIRST( value [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### MIN (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the minimum value within a specified window of rows, considering sorting and partitioning. ```APIDOC ## MIN (window) ### Description Returns the minimum value. If `value`: - number — Returns the smallest number. - date — Returns the earliest date. - string — Returns the first value in the alphabetic order. ### Syntax `MIN( value [ TOTAL | WITHIN ... | AMONG ... ] )` or `MIN( value [ TOTAL | WITHIN ... | AMONG ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### MMAX (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the moving maximum of values within a defined window size, based on sort order and arguments. ```APIDOC ## MMAX (window) ### Description Returns the moving maximum of values in a fixed-size window defined by the sort order and arguments: | `rows_1` | `rows_2` | Window | |:-----------|:-----------|:----------------------------------------------------------------------| | positive | - | The current row and `rows_1` preceding rows. | | negative | - | The current row and -`rows_1` following rows. | | any sign | any sign | `rows_1` preceding rows, the current row and `rows_2` following rows. | Window functions with a similar behavior: [MSUM](MSUM.md), [MCOUNT](MCOUNT.md), [MMIN](MMIN.md), [MAVG](MAVG.md). See also [MAX](MAX.md), [RMAX](RMAX.md). ### Syntax `MMAX( value, rows_1 [ , rows_2 ] )` or `MMAX( value, rows_1 [ , rows_2 ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### MMIN (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the moving minimum of values within a defined window size, based on sort order and arguments. ```APIDOC ## MMIN (window) ### Description Returns the moving minimum of values in a fixed-size window defined by the sort order and arguments: | `rows_1` | `rows_2` | Window | |:-----------|:-----------|:----------------------------------------------------------------------| | positive | - | The current row and `rows_1` preceding rows. | | negative | - | The current row and -`rows_1` following rows. | | any sign | any sign | `rows_1` preceding rows, the current row and `rows_2` following rows. | Window functions with a similar behavior: [MSUM](MSUM.md), [MCOUNT](MCOUNT.md), [MMAX](MMAX.md), [MAVG](MAVG.md). See also [MIN](MIN.md), [RMIN](RMIN.md). ### Syntax `MMIN( value, rows_1 [ , rows_2 ] )` or `MMIN( value, rows_1 [ , rows_2 ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### DAYOFWEEK Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the day of the week according to ISO 8601. An optional parameter can specify the first day of the week. ```APIDOC ## DAYOFWEEK Function ### Description Returns the day of the week according to [ISO 8601]. Monday is 1, and Sunday is 7. ### Syntax `DAYOFWEEK( datetime [ , firstday ] )` ### Parameters * `datetime`: The date or datetime value. * `firstday` (Optional): Specifies the first day of the week. Valid values include: - `"Monday"`, `"Mon"` - `"Tuesday"`, `"Tue"` - `"Wednesday"`, `"Wed"` - `"Thursday"`, `"Thu"` - `"Friday"`, `"Fri"` - `"Saturday"`, `"Sat"` - `"Sunday"`, `"Sun"` ``` -------------------------------- ### DAY Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the day of the month from a given date. ```APIDOC ## DAY Function ### Description Returns the number of the day in the month of the specified date `datetime`. ### Syntax `DAY( datetime )` ### Parameters * `datetime`: The date or datetime value from which to extract the day. ``` -------------------------------- ### ARRAY Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Creates an array containing the values provided as arguments. ```APIDOC ## ARRAY **Syntax:**`ARRAY( value_1, value_2, value_3 [ , ... ] )` Returns an array containing the passed values. ``` -------------------------------- ### MAX (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the maximum value within a specified window context. Applicable for numbers, dates, and strings, returning the largest, latest, or last alphabetically, respectively. ```APIDOC ## MAX (window) ### Description Returns the maximum value within a specified window context. Applicable for numbers, dates, and strings, returning the largest, latest, or last alphabetically, respectively. ### Syntax `MAX( value TOTAL | WITHIN ... | AMONG ... )` or `MAX( value TOTAL | WITHIN ... | AMONG ... [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### MSUM (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the moving sum of values within a defined window size, based on sort order and arguments. ```APIDOC ## MSUM (window) ### Description Returns the moving sum of values in a fixed-size window defined by the sort order and arguments: | `rows_1` | `rows_2` | Window | |:-----------|:-----------|:----------------------------------------------------------------------| | positive | - | The current row and `rows_1` preceding rows. | | negative | - | The current row and -`rows_1` following rows. | | any sign | any sign | `rows_1` preceding rows, the current row and `rows_2` following rows. | Window functions with a similar behavior: [MCOUNT](MCOUNT.md), [MMIN](MMIN.md), [MMAX](MMAX.md), [MAVG](MAVG.md). See also [SUM](SUM.md), [RSUM](RSUM.md). ### Syntax `MSUM( value, rows_1 [ , rows_2 ] )` or `MSUM( value, rows_1 [ , rows_2 ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### LEAST Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the smallest value among the provided arguments. The data type of the arguments determines the comparison logic (numeric, alphabetical, chronological, or boolean). ```APIDOC ## LEAST ### Description Returns the smallest value among the provided arguments. The data type of the arguments determines the comparison logic (numeric, alphabetical, chronological, or boolean). ### Syntax `LEAST( value_1, value_2, value_3 [ , ... ] )` ### See Also [GREATEST](GREATEST.md) ``` -------------------------------- ### MCOUNT (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the moving count of non-NULL values within a specified window. The window is defined by the sort order and arguments, allowing for flexible window sizes. ```APIDOC ## MCOUNT (window) ### Description Returns the moving count of (non-`NULL`) values in a fixed-size window defined by the sort order and arguments. ### Syntax `MCOUNT( value, rows_1 [ , rows_2 ] )` or `MCOUNT( value, rows_1 [ , rows_2 ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ### Window Definition | `rows_1` | `rows_2` | Window | |:-----------|:-----------|:----------------------------------------------------------------------| | positive | - | The current row and `rows_1` preceding rows. | | negative | - | The current row and -`rows_1` following rows. | | any sign | any sign | `rows_1` preceding rows, the current row and `rows_2` following rows. | ### See Also [MSUM](MSUM.md), [MMIN](MMIN.md), [MMAX](MMAX.md), [MAVG](MAVG.md), [COUNT](COUNT.md), [RCOUNT](RCOUNT.md) ``` -------------------------------- ### LEN (array) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the number of items in an array. ```APIDOC ## LEN (array) ### Description Returns the number of items in the given array value. ### Syntax `LEN( value )` ``` -------------------------------- ### MAVG (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the moving average of values within a specified window. The window is defined by the sort order and arguments, allowing for flexible window sizes. ```APIDOC ## MAVG (window) ### Description Returns the moving average of values in a fixed-size window defined by the sort order and arguments. ### Syntax `MAVG( value, rows_1 [ , rows_2 ] )` or `MAVG( value, rows_1 [ , rows_2 ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ### Window Definition | `rows_1` | `rows_2` | Window | |:-----------|:-----------|:----------------------------------------------------------------------| | positive | - | The current row and `rows_1` preceding rows. | | negative | - | The current row and -`rows_1` following rows. | | any sign | any sign | `rows_1` preceding rows, the current row and `rows_2` following rows. | ### See Also [MSUM](MSUM.md), [MCOUNT](MCOUNT.md), [MMIN](MMIN.md), [MMAX](MMAX.md), [AVG](AVG.md), [RAVG](RAVG.md) ``` -------------------------------- ### RMIN (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the minimum value within a growing or shrinking window defined by the sort order and direction. Supports optional window frame clauses. ```APIDOC ## RMIN (window) ### Description Returns the minimum of all values in a growing (or shrinking) window defined by the sort order and the value of `direction`. ### Syntax `RMIN( value [ , direction ] )` or `RMIN( value [ , direction ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ### Parameters * **value**: The expression to find the minimum of. * **direction** (Optional): Specifies the window direction. Accepts `"asc"` (default) or `"desc"`. * `"asc"`: Window starts from the first row and ends at the current row. * `"desc"`: Window starts from the current row and ends at the last row. ### Window Frame Clauses (Optional) * `TOTAL`: Includes all rows in the partition. * `WITHIN ...`: Defines a specific range within the partition. * `AMONG ...`: Defines a specific range within the partition. ### Ordering * `ORDER BY ...`: Specifies the order of rows within the window. ### Filtering * `BEFORE FILTER BY ...`: Filters rows before the window calculation. ### Related Functions * Similar behavior: [RSUM](RSUM.md), [RCOUNT](RCOUNT.md), [RMAX](RMAX.md), [RAVG](RAVG.md). * See also: [MIN](MIN.md), [MMIN](MMIN.md). ``` -------------------------------- ### Indicator with Measure by Category and Trend Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/visualization-ref/indicator-chart.md Create an indicator that shows sales figures by category, including conditional formatting for values above or below a threshold and trend indicators (up/down arrows). ```markdown SIZE('Sales: ' + COLOR(STR([Sales])+ ' ₽', 'green'), '26px') + BR() + COLOR(" ▲ ", "green")+': More than ₽50,000,000 | ' + COLOR(" ▼ ", "red") + ': ₽50,000,000 or less' + BR() + BR() + SIZE( COLOR('| ' + STR(SUM_IF([Sales],[ProductCategory]='Home appliances'))+ ' ₽ | ', 'blue') + COLOR(if(SUM_IF([Sales],[ProductCategory]='Home appliances')>50,000,000, " ▲ "," ▼ "), if(SUM_IF([Sales],[ProductCategory]='Home appliances')>50,000,000,"green", "red")), '20px') + BR() + 'Home appliances' + BR() + BR() + SIZE( COLOR('| ' + STR(SUM_IF([Sales],[ProductCategory]='Household chemicals'))+ ' ₽ | ', 'green') + COLOR(if(SUM_IF([Sales],[ProductCategory]='Household chemicals')>50,000,000, " ▲ "," ▼ "), if(SUM_IF([Sales],[ProductCategory]='Household chemicals')>50,000,000,"green", "red")), '20px') + BR() + 'Household chemicals' + BR() + BR() + SIZE( COLOR('| ' + STR(SUM_IF([Sales],[ProductCategory]='Household products'))+ ' ₽ | ', 'violet') + COLOR(if(SUM_IF([Sales],[ProductCategory]='Household products')>50,000,000, " ▲ "," ▼ "), if(SUM_IF([Sales],[ProductCategory]='Household products')>50,000,000,"green", "red")), '20px') + BR() + 'Household products' ``` -------------------------------- ### ARR_PRODUCT Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates and returns the product of all elements within an array. ```APIDOC ## ARR_PRODUCT **Syntax:**`ARR_PRODUCT( array )` Returns the product of elements in the `array`. ``` -------------------------------- ### LEFT Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts a specified number of characters from the beginning of a string. ```APIDOC ## LEFT ### Description Returns a string that contains the specified number of characters from the beginning of the input string. ### Syntax `LEFT( string, number )` ``` -------------------------------- ### LEN Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the number of characters in a string or the number of items in an array. ```APIDOC ## LEN ### Description Returns the number of characters in a string or the number of items in an array. ### Syntax `LEN( value )` ``` -------------------------------- ### RCOUNT (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the count of values within a growing or shrinking window defined by the sort order and direction. Supports optional window frame clauses. ```APIDOC ## RCOUNT (window) ### Description Returns the count of all values in a growing (or shrinking) window defined by the sort order and the value of `direction`. ### Syntax `RCOUNT( value [ , direction ] )` or `RCOUNT( value [ , direction ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ### Parameters * **value**: The expression to count. * **direction** (Optional): Specifies the window direction. Accepts `"asc"` (default) or `"desc"`. * `"asc"`: Window starts from the first row and ends at the current row. * `"desc"`: Window starts from the current row and ends at the last row. ### Window Frame Clauses (Optional) * `TOTAL`: Includes all rows in the partition. * `WITHIN ...`: Defines a specific range within the partition. * `AMONG ...`: Defines a specific range within the partition. ### Ordering * `ORDER BY ...`: Specifies the order of rows within the window. ### Filtering * `BEFORE FILTER BY ...`: Filters rows before the window calculation. ### Related Functions * Similar behavior: [RSUM](RSUM.md), [RMIN](RMIN.md), [RMAX](RMAX.md), [RAVG](RAVG.md). * See also: [COUNT](COUNT.md), [MCOUNT](MCOUNT.md). ``` -------------------------------- ### FLOAT Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Converts an expression to a fractional number (float) format. ```APIDOC ## FLOAT ### Description Converts the `expression` expression to fractional number format according to the following rules: | Type | Value | |:----------------------------------------------|:------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | `Fractional number | Integer` | Original value. | | `Date | Datetime` | [Unix time](https://en.wikipedia.org/wiki/Unix_time) corresponding to the date and time. If the value contains time zone data, it's used in the calculation. If the time zone is unknown, the time is set in UTC. | | `String` | A number from a decimal string. | | `Boolean` | `TRUE` — `1.0`, `FALSE` — `0.0`. | ### Syntax `FLOAT( expression )` ``` -------------------------------- ### OR Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Performs a logical OR operation between two Boolean expressions. ```APIDOC ## OR ### Description Performs a Boolean join of two expressions with the `OR` condition. ### Syntax `value_1 OR value_2` ``` -------------------------------- ### MINUTE Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts the minute component from a datetime value. ```APIDOC ## MINUTE ### Description Returns the number of the minute in the hour of the specified date `datetime`. When the date is specified without time, it returns `0`. ### Syntax `MINUTE( datetime )` ``` -------------------------------- ### DATETIME Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Converts an expression to a date and time format. It can optionally convert to a specified timezone. ```APIDOC ## DATETIME Function ### Description Converts an expression to date and time format. When converting `Date` to `DateTime`, the time is set to '00:00:00'. ### Syntax `DATETIME( expression [ , timezone ] )` ### Parameters * `expression`: The expression to convert. Must be in `YYYY-MM-DDThh:mm:ss` or `YYYY-MM-DD hh:mm:ss` format. Numeric values are interpreted as Unix time. * `timezone` (Optional): The timezone to convert the date and time to, specified in `Region/Data_Zone` format. ``` -------------------------------- ### RMAX (window) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the maximum value within a growing or shrinking window defined by the sort order and direction. Supports optional window frame clauses. ```APIDOC ## RMAX (window) ### Description Returns the maximum of all values in a growing (or shrinking) window defined by the sort order and the value of `direction`. ### Syntax `RMAX( value [ , direction ] )` or `RMAX( value [ , direction ] [ TOTAL | WITHIN ... | AMONG ... ] [ ORDER BY ... ] [ BEFORE FILTER BY ... ] )` ### Parameters * **value**: The expression to find the maximum of. * **direction** (Optional): Specifies the window direction. Accepts `"asc"` (default) or `"desc"`. * `"asc"`: Window starts from the first row and ends at the current row. * `"desc"`: Window starts from the current row and ends at the last row. ### Window Frame Clauses (Optional) * `TOTAL`: Includes all rows in the partition. * `WITHIN ...`: Defines a specific range within the partition. * `AMONG ...`: Defines a specific range within the partition. ### Ordering * `ORDER BY ...`: Specifies the order of rows within the window. ### Filtering * `BEFORE FILTER BY ...`: Filters rows before the window calculation. ### Related Functions * Similar behavior: [RSUM](RSUM.md), [RCOUNT](RCOUNT.md), [RMIN](RMIN.md), [RAVG](RAVG.md). * See also: [MAX](MAX.md), [MMAX](MMAX.md). ``` -------------------------------- ### Convert to DateTime Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Converts an expression to date and time format. Supports 'YYYY-MM-DDThh:mm:ss' or 'YYYY-MM-DD hh:mm:ss' formats. Optionally converts to a specified timezone. ```sql DATETIME('2018-07-12 11:07:13') DATETIME('2018-07-12T11:07:13', 'America/New_York') ``` -------------------------------- ### ANY Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns one of the values from a group. This is a non-deterministic aggregation, meaning the result may vary across queries. ```APIDOC ## ANY **Syntax:** `ANY( value )` or `ANY( value [ FIXED ... | INCLUDE ... | EXCLUDE ... ] [ BEFORE FILTER BY ... ] )` Returns one of the values of `value` from the group. This is a nondeterministic aggregation — the result may vary for the same data over multiple queries. ``` -------------------------------- ### Parse DateTime Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Converts a value to date and time format, supporting multiple input formats. Processing is done on the {{ CH }} side. ```sql DATETIME_PARSE('2018-07-12 11:07:13') ``` -------------------------------- ### MIN Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the minimum value from a set of values. The type of the returned value depends on the input type (number, date, or string). ```APIDOC ## MIN ### Description Returns the minimum value. If `value`: - number — Returns the smallest number. - date — Returns the earliest date. - string — Returns the first value in the alphabetic order. ### Syntax `MIN( value )` or `MIN( value [ FIXED ... | INCLUDE ... | EXCLUDE ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### DATETIME_PARSE Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Converts a value to date and time format, supporting multiple input formats. This function is processed on the ClickHouse source side. ```APIDOC ## DATETIME_PARSE Function ### Description Converts a value expression to date and time format, supporting multiple formats. Processed on the {{ CH }} source side. ### Syntax `DATETIME_PARSE( value )` ### Parameters * `value`: The expression to convert to date and time format. Refer to {{ CH }} documentation for supported formats. ``` -------------------------------- ### AND Operator Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Performs a Boolean join of two expressions using the AND condition. ```APIDOC ## AND **Syntax:**`value_1 AND value_2` Performs a Boolean join of two expressions with the `AND` condition. ``` -------------------------------- ### GEOPOINT Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Creates a Geopoint type value from coordinates or a string. ```APIDOC ## GEOPOINT ### Description Generates a Geopoint type value. For the input, it accepts a string, a "geopoint" type value, or coordinates — latitude `value_1` and longitude `value_2`. If a single string is input, it must contain a list of two numbers (latitude and longitude) in JSON syntax. ### Syntax `GEOPOINT( value_1 [ , value_2 ] )` ``` -------------------------------- ### ARR_STR Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Concatenates elements of an array into a string, using a specified delimiter and a string for NULL values. ```APIDOC ## ARR_STR **Syntax:**`ARR_STR( array [ , delimiter [ , null_str ] ] )` Concatenates elements of the array `array` using `delimiter` as a delimiter (comma by default) and `null_str` as a `NULL` string (`NULL` items are skipped by default). See also [STR](STR.md) ``` -------------------------------- ### ALL_CONCAT Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns a string containing all unique values of an expression, delimited by a specified separator. If no separator is provided, a comma is used. ```APIDOC ## ALL_CONCAT **Syntax:** `ALL_CONCAT( expression [ , separator ] )` or `ALL_CONCAT( expression [ , separator ] [ FIXED ... | INCLUDE ... | EXCLUDE ... ] [ BEFORE FILTER BY ... ] )` Returns a string that contains all unique values of `expression` delimited by `separator` (if `separator` is not specified, a comma is used). ``` -------------------------------- ### Indicator with Emoji for Value Comparison Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/visualization-ref/indicator-chart.md Use emojis within a calculated field to visually represent indicator values, such as comparing average spend against a threshold. This enhances informativeness. ```Calculation IF([Average spend]>2200, CONCAT("✔️",STR(ROUND([Average spend]))),CONCAT("🔻",STR(round([Average spend])))) ``` -------------------------------- ### ASCII Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the numeric representation (ASCII value) of the first character of a given string. ```APIDOC ## ASCII **Syntax:**`ASCII( string )` Returns the numeric representation of the first character of the string. ``` -------------------------------- ### ASIN Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates and returns the arcsine of a number in radians. ```APIDOC ## ASIN **Syntax:**`ASIN( number )` Returns the arcsine of `number` in radians. ``` -------------------------------- ### ARG_MIN Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the value associated with the minimum value of a specified expression within a group. If multiple values share the minimum, the first encountered is returned. ```APIDOC ## ARG_MIN **Syntax:** `ARG_MIN( value, expression_to_minimize )` or `ARG_MIN( value, expression_to_minimize [ FIXED ... | INCLUDE ... | EXCLUDE ... ] [ BEFORE FILTER BY ... ] )` Returns `value` for the minimum value of `expression_to_minimize` in the group. If multiple values of `value` match the minimum value of `expression_to_minimize`, then the first one encountered is returned. This makes the function non-deterministic. ``` -------------------------------- ### REGEXP_EXTRACT_ALL Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts all substrings from a given string that match a specified regular expression pattern. ```APIDOC ## REGEXP_EXTRACT_ALL ### Description Returns all `string` substrings matching the `pattern` regex. For regexes with subgroups, it only works for the first subgroup. ### Syntax `REGEXP_EXTRACT_ALL( string, pattern )` ### Parameters * **string**: The input string to search within. * **pattern**: The regular expression pattern to match. ``` -------------------------------- ### Negation (-) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the number with its sign inverted. ```APIDOC ## Negation (-) ### Description Returns the number `value` with the opposite sign. ### Syntax `-value` ``` -------------------------------- ### Extract Date Part Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns a specific part of a date as an integer. Supports various units like year, month, day, and hour. The 'dayofweek' unit allows specifying the first day of the week. ```sql DATEPART(#2018-07-12 11:07:13#, "month") = 7 ``` -------------------------------- ### MONTH Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts the month component from a datetime value. ```APIDOC ## MONTH ### Description Returns the number of the month in the year of the specified date `datetime`. ### Syntax `MONTH( datetime )` ``` -------------------------------- ### AT_DATE Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Re-evaluates a measure for a specific date or time expression. It allows retrieving a measure at the beginning, end, or a specific point within a period. ```APIDOC ## AT_DATE **Syntax:** `AT_DATE( measure, date_dimension, date_expr )` or `AT_DATE( measure, date_dimension, date_expr [ BEFORE FILTER BY ... ] [ IGNORE DIMENSIONS ... ] )` Re-evaluate `measure` for a date/time specified by `date_expr`. It allows to get the measure at the beginning and at the end of a period, or for the specified date. The `date_dimension` argument is the dimension along which the offset is made. You can use the following as the `date_expr` argument: * Certain date. * Function [TODAY](TODAY.md) to obtain the current date. * Functions to calculate date and time. See also [AGO](AGO.md), [LAG](LAG.md). ``` -------------------------------- ### ARR_MIN Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the least element from an array. ```APIDOC ## ARR_MIN **Syntax:**`ARR_MIN( array )` Returns the least of elements in the `array`. ``` -------------------------------- ### REPLACE (string) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Replaces all occurrences of a specified substring within a string with a new replacement string. ```APIDOC ## REPLACE (string) ### Description Searches for the substring `substring` in the string `string` and replaces it with the string `replace_with`. If the substring is not found, the string is not changed. ### Syntax `REPLACE( string, substring, replace_with )` ### Parameters * **string**: The input string to perform replacements on. * **substring**: The substring to search for. * **replace_with**: The string to replace the found substring with. ``` -------------------------------- ### DIV_SAFE Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Safely divides two numbers, returning a fallback value if division by zero occurs. ```APIDOC ## DIV_SAFE ### Description Divides `numerator` by `denominator`. Returns `fallback_value` if division by zero occurs. If the number `fallback_value` is omitted, it is assumed to be `NULL`. The result is rounded down to the nearest integer. ### Syntax `DIV_SAFE( numerator, denominator [ , fallback_value ] )` ``` -------------------------------- ### MEDIAN Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates the median value of a given set of values. For an even number of items, it returns the greatest of the neighboring items in the central position. ```APIDOC ## MEDIAN ### Description Returns the median value. For an even number of items, it returns the greatest of the neighboring items in the central position. ### Syntax `MEDIAN( value )` or `MEDIAN( value [ FIXED ... | INCLUDE ... | EXCLUDE ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### DATEPART Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts a specific part of a date or datetime value as an integer. Supports various units like year, month, day, hour, etc., and an optional first day of the week for 'dayofweek'. ```APIDOC ## DATEPART Function ### Description Returns a part of the date as an integer. ### Syntax `DATEPART( datetime, unit [ , firstday ] )` ### Parameters * `datetime`: The date or datetime value from which to extract a part. * `unit`: A string specifying the part of the date to return. Supported values include: - `"year"`: The year number. - `"quarter"`: The quarter of the year (1-4). - `"month"`: The month number (1-12). - `"week"`: The week number of the year (ISO 8601). - `"dayofweek"`, `"dow"`: The day of the week. - `"day"`: The day of the month. - `"hour"`: The hour of the day. - `"minute"`: The minute of the hour. - `"second"`: The second of the minute. * `firstday` (Optional): Specifies the first day of the week when `unit` is `"dayofweek"`. Defaults to Monday. ``` -------------------------------- ### ARR_SUM Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates and returns the sum of all elements within an array. ```APIDOC ## ARR_SUM **Syntax:**`ARR_SUM( array )` Returns the sum of elements in the `array`. ``` -------------------------------- ### RIGHT Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts a specified number of characters from the end of a string. ```APIDOC ## RIGHT ### Description Returns a string that contains the number of characters specified in `number` from the end of the string `string`. ### Syntax `RIGHT( string, number )` ### Parameters * **string**: The input string. * **number**: The number of characters to extract from the end. ``` -------------------------------- ### GREATEST Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the greatest value from a list of values. ```APIDOC ## GREATEST ### Description Returns the greatest value. See also [LEAST](LEAST.md). Depending on the specified data type, it returns: - The greatest number. - The last string in alphabetical order. - The latest date. - `TRUE` when selecting between `TRUE` and `FALSE` for Boolean type. ### Syntax `GREATEST( value_1, value_2, value_3 [ , ... ] )` ``` -------------------------------- ### ARR_AVG Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Calculates and returns the average of all elements within an array. ```APIDOC ## ARR_AVG **Syntax:**`ARR_AVG( array )` Returns the average of elements in the `array`. ``` -------------------------------- ### MAX Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the maximum value from a set of values. For numbers, it returns the largest; for dates, the latest; and for strings, the last alphabetically. ```APIDOC ## MAX ### Description Returns the maximum value. If `value` is a number, it returns the largest number. If it's a date, it returns the latest date. If it's a string, it returns the last value in alphabetical order. ### Syntax `MAX( value )` or `MAX( value [ FIXED ... | INCLUDE ... | EXCLUDE ... ] [ BEFORE FILTER BY ... ] )` ``` -------------------------------- ### GEOPOLYGON Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Converts a value into a Geopolygon format. ```APIDOC ## GEOPOLYGON ### Description Converts the `value` expression to [geopolygon](../dataset/data-types.md#geopolygon) format. At input, the function accepts strings in `[[[lat_1,lon_1], [lat_2,lon_2], ..., [lat_N-1,lon_N-1], [lat_N,lon_N]]]` format. ### Syntax `GEOPOLYGON( value )` ``` -------------------------------- ### NOT Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Inverts a Boolean value. ```APIDOC ## NOT ### Description Inverts a Boolean value. ### Syntax `NOT value` ``` -------------------------------- ### HOUR Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts the hour component from a datetime value. ```APIDOC ## HOUR ### Description Returns the number of the hour in the day of the specified date and time `datetime`. When the date is specified without time, it returns `0`. ### Syntax `HOUR( datetime )` ``` -------------------------------- ### ARG_MAX Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the value associated with the maximum value of a specified expression within a group. If multiple values share the maximum, the first encountered is returned. ```APIDOC ## ARG_MAX **Syntax:** `ARG_MAX( value, expression_to_maximize )` or `ARG_MAX( value, expression_to_maximize [ FIXED ... | INCLUDE ... | EXCLUDE ... ] [ BEFORE FILTER BY ... ] )` Returns `value` for the maximum value of `expression_to_maximize` in the group. If multiple values of `value` match the maximum value of `expression_to_maximize`, then the first one encountered is returned. This makes the function non-deterministic. ``` -------------------------------- ### REGEXP_MATCH Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Checks if a given string contains any substring that matches a specified regular expression pattern. ```APIDOC ## REGEXP_MATCH ### Description Returns 'TRUE' if the string `string` has a substring that matches the regular expression pattern `pattern`. ### Syntax `REGEXP_MATCH( string, pattern )` ### Parameters * **string**: The input string to check. * **pattern**: The regular expression pattern to match. ``` -------------------------------- ### REPLACE (array) Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Replaces all occurrences of a specific element within an array with a new element. ```APIDOC ## REPLACE (array) ### Description Replaces each `array` element equal to `old` with `new`. ### Syntax `REPLACE( array, old, new )` ### Parameters * **array**: The input array. * **old**: The element to be replaced. * **new**: The element to replace with. ``` -------------------------------- ### REGEXP_REPLACE Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Replaces substrings within a string that match a regular expression pattern with a specified replacement string. ```APIDOC ## REGEXP_REPLACE ### Description Searches for a substring in the string `string` using the regular expression pattern `pattern` and replaces it with the string `replace_with`. If the substring is not found, the string is not changed. ### Syntax `REGEXP_REPLACE( string, pattern, replace_with )` ### Parameters * **string**: The input string to perform replacements on. * **pattern**: The regular expression pattern to search for. * **replace_with**: The string to replace the matched substrings with. ``` -------------------------------- ### ROUND Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Rounds a number to a specified number of decimal places or to the nearest integer. ```APIDOC ## ROUND ### Description Rounds the number `number` to the number of decimal digits specified in `precision`. If the number `precision` is omitted, `number` is rounded to the nearest integer. ### Syntax `ROUND( number [ , precision ] )` ### Parameters * **number**: The number to round. * **precision** (Optional): The number of decimal digits to round to. If omitted, rounds to the nearest integer. ``` -------------------------------- ### REGEXP_EXTRACT Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts a substring from a given string that matches a specified regular expression pattern. ```APIDOC ## REGEXP_EXTRACT ### Description Returns the substring `string` that matches the regular expression `pattern`. ### Syntax `REGEXP_EXTRACT( string, pattern )` ### Parameters * **string**: The input string to search within. * **pattern**: The regular expression pattern to match. ``` -------------------------------- ### AGO Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Re-evaluates a measure for a date/time with a given offset. It allows for time-based calculations relative to a specified date dimension and unit. ```APIDOC ## AGO **Syntax:** `AGO( measure, date_dimension [ , unit [ , number ] ] )` or `AGO( measure, date_dimension [ , unit [ , number ] ] [ BEFORE FILTER BY ... ] [ IGNORE DIMENSIONS ... ] )` Re-evaluate `measure` for a date/time with a given offset. The `date_dimension` argument is the dimension along which the offset is made. The `number` argument sets the offset in units of the `unit` argument. Set as an integer. It may take negative values. The default value is `1`. The `unit` argument sets the unit for `number`. It may take the following values: - `"year"`; - `"month"`; - `"week"`; - `"day"` (default value); - `"hour"`; - `"minute"`; - `"second"`. Can also be used as `AGO( measure, date_dimension, number )`. In this case, the `unit` argument takes the `"day"` value. See also [AT_DATE](AT_DATE.md), [LAG](LAG.md). ``` -------------------------------- ### ARR_MAX Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns the greatest element from an array. ```APIDOC ## ARR_MAX **Syntax:**`ARR_MAX( array )` Returns the greatest of elements in the `array`. ``` -------------------------------- ### REGEXP_EXTRACT_NTH Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Extracts the Nth occurrence of a substring from a given string that matches a specified regular expression pattern. ```APIDOC ## REGEXP_EXTRACT_NTH ### Description Returns a substring `string` that matches the regular expression pattern `pattern` starting from the specified index. ### Syntax `REGEXP_EXTRACT_NTH( string, pattern, match_index )` ### Parameters * **string**: The input string to search within. * **pattern**: The regular expression pattern to match. * **match_index**: The index of the match to retrieve (1-based). ``` -------------------------------- ### DATETRUNC Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Rounds a datetime value down to a specified unit (e.g., second, minute, day, month). An optional number can be provided to round to a multiple of the unit. ```APIDOC ## DATETRUNC Function ### Description Rounds `datetime` down to the given `unit`. If optional `number` is given, then the value is rounded down to a `number` multiple of `unit`. ### Syntax `DATETRUNC( datetime, unit [ , number ] )` ### Parameters * `datetime`: The date or datetime value to round. * `unit`: The unit to round down to. Supported units include: - `"second"` - `"minute"` - `"hour"` - `"day"` (acts as the day of the year if `number` is specified) - `"week"` - `"month"` - `"quarter"` - `"year"` * `number` (Optional): A number specifying the multiple of the `unit` to round down to. Defaults to 1. ``` -------------------------------- ### ARR_INTERSECT Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Returns an array containing elements that are present in all provided arrays. The order of elements is not guaranteed, and duplicates are removed. ```APIDOC ## ARR_INTERSECT **Syntax:**`ARR_INTERSECT( array_1, array_2, array_3 [ , ... ] )` Returns an array of elements that occur in every array provided as an argument. The function does not put such elements in any particular order. Duplicate elements are only added once. ``` -------------------------------- ### ARR_REMOVE Function Source: https://github.com/datalens-tech/docs/blob/main/en/datalens/function-ref/all.md Removes all occurrences of a specified value from an array. ```APIDOC ## ARR_REMOVE **Syntax:**`ARR_REMOVE( array, value )` Removes all `array` elements equal to `value`. ```