Generate
Applies a set to each member of another set, and then joins the resulting sets by union. Alternatively, this function returns a concatenated string created by evaluating a string expression over a set.
Syntax
Set expression syntax Generate( Set_Expression1 , Set_Expression2 , ALL ) String expression syntax Generate( Set_Expression1 , String_Expression , Delimiter )
Arguments
Set_Expression1 | MDX expression that returns a set. |
|---|---|
Set_Expression2 | MDX expression that returns a set. |
String_Expression | String expression |
Delimiter | A valid delimiter expressed as a string expression. |
Examples
Set expression example
The following example could be used as a calculated member in Sprint dimension to retrieve the Last closed sprint from each board:
Aggregate(
Generate(
-- set expression1 - filters all boards
[Sprint].[Board].Members,
-- set expression2 - for each board, pulls in the last completed sprint
Tail(
Filter(
[Sprint].CurrentMember.Children,
[Sprint].CurrentMember.GetBoolean("Closed")),
-- 1st last closed sprint in each board
1)
.Item(0)
)
)
See example report Active (multiple) sprints story points burn-down in our demo account. The report uses a calculated member Last closed (completed) sprints as a selection option on Pages. The report has a selection of two other similar calculated members Closed Sprints 2nd last cycle and Closed Sprints 3rd last cycle. They represent closed sprints 2 cycles ago and 3 cycles ago from each board.
String expression examples
Here is an example to show a list of version releases based on release dates
Generate(
Filter(
[Fix Version].[Version].Members,
DateInPeriod(
[Fix Version].CurrentMember.get('Release date'),
[Time].CurrentHierarchyMember
) AND
([Time].CurrentHierarchy.DefaultMember,
[Measures].[Issues created]) > 0),
-- show version name
[Fix Version].CurrentMember.Name,
', '
)
See example report Version releases in our demo account. The calculated measures Version release uses the formula above to show a list of versions with a release dates as a string for each period.
The default Issue property Issue Sub-task keys uses the function Generate to show all sub-task keys for any issue:
CASE WHEN NOT
-- Sub-task keys property stores max 255 charters
IsEmpty([Issue].CurrentHierarchyMember.get('Sub-task keys'))
THEN
-- generate all sub-task keys list from Sub-task hierarchy
Generate([Issue.Sub-task].[Parent].getMemberByKey(
[Issue].CurrentHierarchyMember.Key).Children,
[Issue.Sub-task].CurrentMember.getString('KEY'), ',')
END