OCLOperators groupBy
Charles Olet (talk | contribs) No edit summary |
Charles Olet (talk | contribs) 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. | |||
[[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.. | 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.. | ||
Line 12: | Line 11: | ||
To get the product sales made on specific dates | To get the product sales made on specific dates | ||
[[File:ocl-groupby-expression.png|alt=Ocl groupby operator|frameless|791x791px]] | [[File:ocl-groupby-expression-for-collections.png|alt=Ocl groupby operator|frameless|791x791px]] | ||
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 and sales amount. | To get product sales made on specific dates with the quantity and and sales amount. | ||
Line 23: | Line 22: | ||
|- | |- | ||
|Part1 | |Part1 | ||
|The grouping criteria object accessed as object type <code>.DateAdded</code> instead of <code>.Part1</code> since it is known in | |The grouping criteria object accessed as object type <code>.DateAdded</code> instead of <code>.Part1</code> since it is known and available in groupby result. | ||
|- | |- | ||
|Part2 | |Part2 | ||
|The total quantity sold accessed as <code>.Part2</code> since it is not | |The total quantity sold accessed as <code>.Part2</code> since it is computed not available in the groupby result. | ||
|- | |- | ||
|Part3 | |Part3 | ||
|The total sales amount accessed as <code>.Part3</code> since it is not | |The total sales amount accessed as <code>.Part3</code> since it is also computed and not available in the groupby result. | ||
|} | |} |
Revision as of 01:20, 20 June 2024
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 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
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.
To get product sales made on specific dates with the quantity and and sales amount.
Tuple Parts | Description |
---|---|
Part1 | The grouping criteria object accessed as object type .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 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 56 days ago on 01/20/2025. What links here