OCLOperators groupBy
No edit summary
No edit summary
Line 1: Line 1:
<message>Write the content here to display this box</message>
<message>Write the content here to display this box</message>


OCL groupBy expression groups together a collection of all matching objects based a specified criteria returning a tuple of the grouping criteria object and Collection of the matching objects in the <code>List</code> property.
OCL groupBy expression groups together a collection of all matching objects based on a specified criteria, returning a tuple of the grouping criteria object and a collection of the matching objects in the <code>List</code> property.
 
groupBy is well suited for aggregation with its ability to utilize tuples, enabling the creation of aggregate expressions for extraction of patterns from model-driven data that can be used for statistical analysis.
[[Category:OCL Collection Operators]]
[[Category:OCL Collection Operators]]
groupBy is well suited for aggregation with its ability to utilize tuples enabling the creation of aggregate expressions for extraction of patterns from model-driven data that can be used for statistical analysis..


Example
===== Example =====
[[File:how-to-use-groupby-ocl-operator.png|alt=How to use ocl group by expression|frameless|374x374px]]
 
To get the product sales made on specific dates:


[[File:how-to-use-groupby-ocl-operator.png|alt=How to use ocl group by expression|frameless]]
[[File:ocl-groupby-expression-for-collections.png|alt=Ocl groupby operator|frameless|791x791px]]


To get the product sales made on specific dates
'''NOTE:''' The groupBy expression always returns the grouping object and a collection of matching objects grouped based on the criteria.


[[File:ocl-groupby-expression-for-collections.png|alt=Ocl groupby operator|frameless|791x791px]]
To get product sales made on specific dates with the quantity and sales amount:
Note: The groupBy expression always returns the grouping object and a collection of matching objects grouped based on the criteria.
To get product sales made on specific dates with the quantity and sales amount.


[[File:groupby-aggregation-expression.png|alt=groupby aggregation expression|frameless|854x854px]]
[[File:groupby-aggregation-expression.png|alt=groupby aggregation expression|frameless|865x865px]]
{| class="wikitable"
{| class="wikitable"
|+
|+

Revision as of 05:05, 21 June 2024


OCL groupBy expression groups together a collection of all matching objects based on a specified criteria, returning a tuple of the grouping criteria object and a collection of the matching objects in the List property.

groupBy is well suited for aggregation with its ability to utilize tuples, enabling the creation of aggregate expressions for extraction of patterns from model-driven data that can be used for statistical analysis.

Example

How to use ocl group by expression

To get the product sales made on specific dates:

Ocl groupby operator

NOTE: The groupBy expression always returns the grouping object and a collection of matching objects grouped based on the criteria.

To get product sales made on specific dates with the quantity and sales amount:

groupby aggregation expression

Tuple Parts Description
Part1 The grouping criteria object accessed with grouping object name .DateAdded instead of .Part1 since it is known and available in groupBy result.
Part2 The total quantity sold accessed as .Part2 since it is computed and not available in the groupBy result.
Part3 The total sales amount accessed as .Part3 since it is also computed and not available in the groupBy result.
This page was edited 1 days ago on 06/30/2024. What links here