[{"id":"53ae7f99-150b-4b50-9f72-02f7f2ea5efe","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e371599e-67ae-4635-802b-0ada531e5b5b","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"f309ec90-559b-42bf-955b-492431019196","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"28d36d47-c582-4210-a848-5ba48491bb80","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"9d13df60-758a-4cc3-9cda-8d6234e00821","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"2e473c2c-8b35-40de-bdce-f21478f434bc","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e19a99e0-5b6f-4c8b-b872-47b3e78011bf","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"2f718a98-6d54-4dc1-89c3-6b87cfabd16b","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"df066912-4ce1-4484-b00c-86b34a6e977b","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"1fcab497-8c1f-413e-bce0-f3ae72229e85","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"3d90b977-451c-42ce-a26a-1e32c1082471","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"6433ad22-3173-436a-8ff9-355a17142bc5","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e82311a5-f99e-4075-8710-9a76a2da67a7","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"7bebaae0-d5e2-4db3-ab34-644272d2aed6","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"2c77a1e3-7af7-4dca-88aa-ee59b41d7896","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"5a3f52b5-5b23-473e-bdbc-906381b9a948","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"299d63a8-7f0b-46a4-a152-9a7ca85a2170","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"906b4555-b1b6-4ddb-a290-c13cb8a153a0","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"efa3eb50-4277-46ee-b451-c5096e889fff","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"1d9b7a41-588f-47d1-bb81-f46146e062fb","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"c1687a0f-e3a0-4074-996c-94cbacf49f29","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"269fc082-c3b5-4208-a987-c1a3c1dee620","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"cb76b7de-9b29-4d6b-b644-de3c3c0a1262","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"4dc9d5da-9bf3-4baf-9fae-6b34511062a4","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e4e74cf8-8702-45a6-a536-86d03b66af49","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"abe88d62-9eb6-4113-89f3-abb0cff27c3a","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"f3751417-d894-4cf1-8a8c-c2e7391dd4b1","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"49ae1d04-aba0-4311-8548-df297a5aedc0","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"861d71ff-44db-4563-a24c-e1a389708c19","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"2f6715bc-8b05-4653-8ec5-0dd835dc6035","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"d2f5c978-f4e4-4c18-ab43-e8fbbc6ad92b","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e183d612-0813-4e0f-b217-308d71c14637","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"f8f319ea-ec97-4d69-a862-c6a17191f0f7","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"d895fc4b-55bb-46ee-bd74-7a0abb51650c","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"680fba3c-ad50-41a6-bc56-acd4f229de8f","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"1234e85c-d175-4f94-ac83-b53b5e3596d2","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"8fb554aa-3192-402b-9d6b-1ec2b4b99ea0","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"aff9d5e3-7e18-4287-892f-8d7844e9ddf2","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"6a23926e-a2ac-4c07-ba79-2f7751f098ee","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"51c9c955-8c66-45d8-bb0c-718aee1073da","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"6174a29f-1d15-4a80-a860-d28fdecca505","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"51709a04-b2cd-4465-b2a2-da7beb2e4f15","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"897b8725-abb5-428a-bd7a-a610fae8e28c","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"c00c0609-ac23-4859-8442-be43ed745ad3","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"0996d76b-b253-49a7-9ea8-89d81ce0d42f","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"3c007776-7473-4203-8cc1-9ed79bb512df","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"4bb1ced3-7a10-4719-854b-513729b31e53","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"53155f14-d53e-4d53-a087-0a32d9b088e8","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"279e57c0-0954-49d6-9076-2133a204e24f","tags":[{"product":null,"links":null,"id":"c3c0ef13-c7a9-4649-9fcb-23b3abec175d","name":"New","color":"Red","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"e9c38f09-cfd3-4a78-b2cf-412e3c1b5945","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"754efafe-744e-452e-9e46-833c9b36c763","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]},{"id":"be5fe8a1-1660-4dc4-b7fb-ceb038047086","tags":[{"product":null,"links":null,"id":"2f377cfe-f512-431a-895b-f89af32041ce","name":"Upd","color":"Blue","productId":"c15646e4-63d8-4965-8d62-7549a2986e99"}]}]
        
(Showing Draft Content)

Window Functions

WINDOW functions provide a set of functions for data analysis in a TableSheet. The functions perform calculations across the window (a set of table rows) that are somehow related to the current row and generate a column to display the results. The row for which function evaluation occurs is called the current row.

A window function performs aggregate, ranking, and analytic functions over a particular window and produces a result for each row.

Notes:

  • The results of window functions may have an impact on the row order of the TableSheet.

    If the TableSheet has been sorted or grouped the result will be constant.

  • When there is a tree structure in the hierarchical data of TableSheet, the window function is ineffective.

  • The TableSheet filter executes after the window function is evaluated and filters only the specific rows.

WINDOW can only be used with window functions. By default, it considers the entire row as a window.

Syntax

WINDOW(window_function, [partitionby_function], [orderby_function], [frame_function])

Arguments

This function has the following arguments:

Argument

Description

window_function

[required] The window functions.

[partitionby_function]

[optional] Divide the rows into partitions.

[orderby_function]

[optional] Define the logical order of the rows within each partition.

[frame_function]

[optional] Specify start and end points to combine the rows to a window within the partition against the current row.

WINDOW

The WINDOW function determines the partitioning, ordering, and limiting window before the associated window function is applied.

The WINDOW function changes the sequence of the rows using the PARTITIONBY and ORDERBY parameters.

Note that if multiple WINDOW functions are applied in a view, then the PARTITIONBY and ORDERBY of them must be the same because the order of the entire row will be reordered by the PARTITIONBY and ORDERBY parameters. Otherwise, entire rows will show the sequence from the last applied WINDOW.

Example

WINDOW(ROWNUMBER(), PARTITIONBY([country]))

To know more about all available window functions, please refer to the Window Functions List section.

PARTITIONBY

The PARTITIONBY function divides the row into partitions in ascending order and window functions are applied to each partition separately. If PARTITIONBY is not specified, the entire row will be treated as a window. PARTITIONBY must have one or more column expressions that can be field names or formulas.

Syntax

PARTITIONBY(field_function [, field_function [, ... ] ])

Arguments

This function has the following argument:

Argument

Description

field_function

[required] The field name or formula be partitioned by.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])))

ORDERBY

The ORDERBY defines the logical order of the rows within each partition. It will affect the window specified and the calculation of the window functions. ORDERBY must have one or more column expressions that can be field names or formulas.

Syntax

ORDERBY(field_function [, field_function [, ... ] ])

Arguments

This function has the following argument:

Argument

Description

field_function

[required] The field name or formula be ordered by.

You can also use ORDERASC and ORDERDESC to sort data in ascending or descending order. By default, the sort order is ORDERASC, and NULL values are treated as the lowest value.

Note:

  • If ORDERBY is not specified, the window functions will use all rows in the partition that are equal to FRAMERANGE(-1, -1).

  • If ORDERBY is specified and no FRAMEROWS/FRAMERANGE is specified, the FRAMERANGE(-1, [@]) will be the default range expression to limit the window for the calculation of the window functions.

Syntax

ORDERASC(field function)

ORDERDESC(field function)

Example

WINDOW(SUM([Sales]), ORDERBY([Product], ORDERDESC(QUARTER([@OrderDate]))))

FRAME

The FRAME function specifies start and end points to combine the rows to a window within the partition against the current row. The window functions will use the row set that is specified by the window. A window is closed with start, end, and current rows. A FRAME function can be defined as FRAMFRAMEROWS, FRAMERANGE, or FRAMEGROUPS.

FRAMEROWS

The FRAMEROWS function allows you to limit the rows of the window by specifying a nonnegative integer row count before and after the current row. The start or end row of the partition is used if one of the preceding or following row counts is outside the current partition bounds. The same result is obtained if the preceding or following row is specified as -1. However, if both are outside, no rows are returned.

Parameter

Accepted Value

Description

First Parameter

Indicates the row count before the current row.

-1, [@-n] or [@]

-1: Indicates the bounding of the current partition.

n: Accepts a nonnegative integer that indicates the row count.

[@]: Indicates the position of the current row.

Second Parameter

Indicates the row count after the current row.

-1, [@+n] or [@

Note: The default value is [@] if the second parameter is missing in the FRAMEROWS function.

Syntax

FRAMEROWS(preceding_function [, following_function ])

Arguments

This function has the following arguments:

Argument

Description

preceding_function

[required] A row count preceding the current row.

[following_function]

[optional] A row count following the current row.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(QUARTER([@OrderDate])), FRAMEROWS([@-1], [@]))

FRAMERANGE

The FRAMERANGE function limits the range of the window by specifying a nonnegative number as the distance around the same values from peer rows which have the same value in the current row composed of the ORDERBY columns.

The FRAMERANGE function has two main parameters, each indicating the distance before and after the peer rows of the current row.

Parameter

Accepted Value

Description

First Parameter

Indicates distance before peer rows of the current row.

-1, [@-n]

If the order is descending, it should be [@+n]), or [@].

-1: Indicates the bounding of the current partition.

n: Accepts a nonnegative integer that indicates the distance.

[@]: Indicates the peer rows that have the same value as the current row.

Second Parameter

Indicates the distance after peer rows of the current row.

-1, [@+n]

If the order is descending, it should be [@-n]), or [@].

The frame range is a fully closed interval. It requires the ORDERBY to provide the first column with the numeric data type. However, if there is more than 1 ordered column, only -1 and [@] are accepted.

FRAMERANGE with ORDERBY

  • FRAMERANGE requires ORDERBY to provide only one column with a numeric data type to retrieve the value in the current row to find the tied rows for [@].

  • If ORDERBY is removed, the default frame expression is FRAMERANGE(-1, -1) even if the FRAMERANGE is specified.

  • If ORDERBY contains more than one column, only -1 and [@] can be used in FRAMERANGE, and [@-/+n] will default to -1. The current tied rows may be defined by the combined column values.

FRAMERANGE with NULL

  • If some of the values in the ordered column are NULL, the rows with NULL values will be arranged side by side at the top/bottom within the partition.

  • If the values of current tied rows are NULL, [@+/-n] will be similar to [@+/-0] which is equal to [@].

  • If the values of current tied rows are not NULL, the retrieving of [@+/-n] will stop to the rows with NULL.

Syntax

FRAMERANGE(preceding_function [, following_function ])

Arguments

This function has the following arguments:

Argument

Description

preceding_function

[required] A distance preceding the current row.

[following_function]

[optional] A distance following the current row.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(QUARTER([@OrderDate])), FRAMERANGE([@-1], [@]))


The following image shows how to get the moving average revenue of each product and revenue trends using aggregate window functions.


WindowFunctions

FRAMEGROUPS

The FRAMEGROUPS function specifies the starting and ending boundaries based on the number of "groups" relative to the current group where a “group” refers to the row sets with equivalent values derived from the window ORDERBY.

A group count that is outside the bounds of a partition falls back to the start/end group and is specified if both preceding/following are –1 but if both are outside, none is returned.

Parameter

Accepted Value

Description

First Parameter

Indicates the group count beginning against the current group.

-1, [@-n], [@+n], or [@]

-1: indicates the unbounded (beginning or ending) of the partition.

[@-n] or [@+n]: indicates the group count beside the current group and the ‘n’ accepts a nonnegative integer.

[@]: indicates the position of the current group.

Second Parameter

Indicates the group count ending against the current group.

-1, [@-n], [@+n] or [@]

Note: The default value is [@] if the second parameter is missing in the FRAMEGROUPS function.

Syntax

FRAMEGROUPS(BeginningExpression, [EndingExpression], [ExcludeMode])

Arguments

This function has the following arguments:

Argument

Description

Beginning_Expression

[required] The group count preceding the current group.

[Ending_Expression]

[optional] The group count following the current group.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(DATEPART([@OrderDate], \"Q\")), FRAMEGROUPS([@-1], [@]))

FRAMEGROUPS with ORDERBY

  • The FRAMEGROUPS require the ORDERBY to provide the column to retrieve the value in the current row to find the tied rows for [@].

  • If the ORDERBY is removed, the default frame expression is FRAMEGROUPS(-1, -1) even if the FRAME GROUPS is specified.

  • If ORDERBY has more than one column, the current tied rows are defined according to the combined column values. For example, if you order by year, quarter, and month, the current tied rows are identified by those same columns.

FRAME with EXCLUDE Mode

The frame with exclude mode is the last parameter in the FRAME expression. It is an optional parameter and has four types.

EXCLUDE NO OTHERS

Indicates that “No rows are Excluded” and is represented by 0.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(DATEPART([@OrderDate], \"Q\")), FRAMEGROUPS([@-1], [@], 1))

The following image shows how to get the monthly average revenue, nearly average revenue of each product and revenue trends using aggregate window functions with EXCLUDE mode.


exclude-no-other

EXCLUDE CURRENT ROW

Indicates that the current row is excluded, however, the other peers of the current row remain for FRAMEGROUPS and FRAMERANGE and are represented by 1.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(DATEPART([@OrderDate], \"Q\")), FRAMEGROUPS([@-1], [@], 1))

The following image shows how to get the monthly average revenue, nearly average revenue of each product, and revenue trends using aggregate window functions with EXCLUDE mode.


exclude-currentrow

EXCLUDE GROUP

Indicates that the current row and the peers are all excluded, even if it’s FRAMEROWS and is represented by 2.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(DATEPART([@OrderDate], \"Q\")), FRAMEGROUPS([@-1], [@], 2))

The following image shows how to get the monthly average revenue, nearly average revenue of each product, and revenue trends using aggregate window functions with EXCLUDE mode.


exclude-group

EXCLUDE TIES

Indicates that the current row remains, however, the other peers are excluded and are represented by 3.

Example

WINDOW(SUM([Sales]), PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(DATEPART([@OrderDate], \"Q\")), FRAMEGROUPS([@-1], [@], 3))

The following image shows how to get the monthly average revenue, nearly average revenue of each product, and revenue trends using aggregate window functions with EXCLUDE mode.


exclude-ties

Window Chaining

Window Chaining allows you to define one window before and reuse the new window which implicitly specifies the PARTITYIONBY, ORDERBY, or Window Frame.

In a pre-defined window, PARTITIONBY, ORDERBY, and Window Frame are overridden by the expression from the new window.

Example

WINDOWDEF(PARTITIONBY([Product], YEAR([@OrderDate])), ORDERBY(DATEPART([@OrderDate], \"Q\")), FRAMEROWS([@-2], [@], 3))

The following image shows how to get the average/quality of revenue of each product and revenue trends using window functions.


window-chaining-formula