Loop (PQL)

Returns a list by applying members of one list to the of the members of another list, and then joins the resulting sets by union.

  • Returned Output: List
  • Library: PQL \ Semantic \ List
  • Version: 2025.10.000
  • Compatibility: Pyramid Query Language (PQL) data sources

Syntax

Loop( <List> , <List> )

Syntax Alternatives

Generate( <List> , <List> )

* Click on the function's arguments above for more details on the input values.

Comments

Loop or 'Generate' returns a new set that is created by iterating through the members of first list and applying them, iteratively, to the members of second list.

  • Each List parameter should be a list or set of elements from an existing hierarchy in the model.
  • For details on how to employ and use this function see the semantic calculation overview.
Different Function types

This function is like the MDX Generate function. It can be used to functionally match the logic of the N-of-N capability in certain circumstances.

Examples

The following example returns a list of the top 2 cities per state based on sales. The first listing of states, is used to iterate over the second listing, which is a top count of cities, where the top 2 cities are chosen for the given state (using 'currentmember') and the sales metric.

Loop( [customers].[State].allmembers(), TopCount( [customers].[City].allmembers, 2, ([measures].[transactions Sales],[customers].[state].currentmember) ) )