--- title: "Lusid.PortfolioGroup" slug: "lusidportfoliogroup" tags: ["luminesce ", "provider", "portfolio group"] updated: 2024-08-21T12:51:39Z published: 2024-08-21T12:51:39Z canonical: "support.lusid.com/lusidportfoliogroup" --- > ## Documentation Index > Fetch the complete documentation index at: https://support.lusid.com/llms.txt > Use this file to discover all available pages before exploring further. # Lusid.PortfolioGroup | **Type** | **Read/write** | **Author** | **Availability** | | --- | --- | --- | --- | | [Data provider](/v1/docs/what-are-a-data-provider-and-a-direct-provider) | Read | Finbourne | Provided with LUSID | Providing you have sufficient [access control permissions](/v1/docs/creating-policies-to-control-access-to-providers-for-different-luminesce-end-users), the `Lusid.PortfolioGroup` provider enables you to write a [Luminesce SQL query](/v1/docs/understanding-the-luminesce-sql-query-syntax) that searches for and retrieves one or more [portfolio groups](/v1/docs/what-is-a-portfolio-group), including portfolios in nested groups (that is, in sub-groups). In conjunction with other providers, you can list transactions, generate holdings and perform valuations for the portfolio group as a whole. > **Note:** By default, `Lusid.PortfolioGroup` cannot retrieve properties. To do this, you must first configure `Lusid.PortfolioGroup` to 'inline' properties. [See how to do this](/v1/docs/how-do-i-configure-luminesce-entity-providers-to-readwrite-properties). `Lusid.PortfolioGroup` considers the portfolio group you search for to be the 'top group'. Since a portfolio group can contain portfolio groups nested up to five levels deep, `Lusid.PortfolioGroup` considers the lowest group found in the hierarchy to be the 'bottom group'. Any portfolio groups in the middle are considered to be part of the 'group path'. **See also:** [Lusid.PortfolioGroup.Writer](/v1/docs/lusidportfoliogroupwriter) ## Basic usage ```sql select * from Lusid.PortfolioGroup where TopGroupScope = and TopGroupCode = ; ``` ## Query parameters `Lusid.PortfolioGroup` has parameters that enable you to filter or refine a query. > **Note:** By default, `Lusid.PortfolioGroup` returns all nested portfolio groups providing they are not empty (that is, do not directly contain a portfolio). You can change both these settings; see below for examples. To list available parameters, their data types, default values, and an explanation for each, run the following query using a [suitable tool](/v1/docs/what-tools-are-available-to-write-luminesce-queries): ```sql select FieldName, DataType, ParamDefaultValue, Description from Sys.Field where TableName = 'Lusid.PortfolioGroup' and FieldType = 'Parameter'; ``` ## Data fields By default, `Lusid.PortfolioGroup` returns a table of data populated with particular fields (columns). You can return a subset of these fields. > **Note:** You must specify the `TopGroupScope` and `TopGroupCode` fields as part of your query. To list fields available to return, their data types, whether fields are considered 'main', and an explanation for each, run the following query using a [suitable tool](/v1/docs/what-tools-are-available-to-write-luminesce-queries): ```sql select FieldName, DataType, IsMain, IsPrimaryKey, SampleValues, Description from Sys.Field where TableName = 'Lusid.PortfolioGroup' and FieldType = 'Column'; ``` > **Note:** Fields marked 'main' are returned by queries that select a caret character, for example `select ^ from Lusid.PortfolioGroup`. ## Examples > **Note:** For more example Luminesce SQL queries, visit our [Github repo](https://github.com/finbourne/luminesce-examples/tree/master/examples). The examples in this section refer to the following portfolio group structure. For simplicity, all the portfolio groups and portfolios are in the same `Groups-Example` scope; the label in each box represents the code: ![](https://cdn.document360.io/d575ad81-c0ed-4980-bbd1-d59ac5c3de82/Images/Documentation/4db9dfbf-9306-4199-98a6-f1122fb2dd40.png?sv=2026-02-06&spr=https&st=2026-11-09T06%3A06%3A17Z&se=2026-11-09T07%3A06%3A17Z&sr=c&sp=r&sig=sAsGRkddvBvZ7AI84BlWbHGFRh0CBtdBiEvOpbep0Is%3D) ### Example 1: Retrieve all the portfolios, including nested Because the `Expand` parameter is set to `True` by default, searching the top `Global` portfolio group returns all the portfolios in the nested groups. Equally, because the `IncludeEmptySubgroups` parameter is set to `False` by default, the `NorthAmerica` and `CAN` portfolio groups are omitted from the results. Although `NorthAmerica` contains sub-groups, it does not directly contain a portfolio itself. Note the `UK-FR-1` portfolio is returned twice, because it is a member of two groups. ```sql select TopGroupCode, BottomGroupCode, GroupCodePath, PortfolioCode from Lusid.PortfolioGroup where TopGroupScope = 'Groups-Example' and TopGroupCode = 'Global' ``` This query returns: | **TopGroupCode** | **BottomGroupCode** | **GroupCodePath** | **PortfolioCode** | | --- | --- | --- | --- | | `Global` | `US` | `Global/US` | `US-1` | | `Global` | `US` | `Global/US` | `US-2` | | `Global` | `Europe` | `Global/Europe` | `EU-1` | | `Global` | `UK` | `Global/Europe/UK` | `UK-1` | | `Global` | `UK` | `Global/Europe/UK` | `UK-FR-1` | | `Global` | `FR` | `Global/Europe/FR` | `UK-FR-1` | | `Global` | `FR` | `Global/Europe/FR` | `FR-1` | ### Example 2: Retrieve just non-nested portfolios Setting `Expand` to `False` returns the only portfolio (`EU-1`) that is directly contained when searching the `NorthAmerica` and `Europe` groups. ```sql select TopGroupCode, BottomGroupCode, PortfolioCode from Lusid.PortfolioGroup where TopGroupScope = 'Groups-Example' and TopGroupCode in ('NorthAmerica', 'Europe') and Expand = False ``` This query returns: | **TopGroupCode** | **BottomGroupCode** | **PortfolioCode** | | --- | --- | --- | | `Europe` | | `EU-1` | ### Example 3: Retrieve portfolio groups even if they are empty Setting `IncludeEmptySubgroups` to `True` returns the empty `CAN` portfolio group when searching the `NorthAmerica` group. ```sql select TopGroupCode, BottomGroupCode, PortfolioCode from Lusid.PortfolioGroup where TopGroupScope = 'Groups-Example' and TopGroupCode = 'NorthAmerica' and IncludeEmptySubgroups = True ``` This query returns: | **TopGroupCode** | **BottomGroupCode** | **PortfolioCode** | | --- | --- | --- | | `NorthAmerica` | `US` | `US-1` | | `NorthAmerica` | `US` | `US-2` | | `NorthAmerica` | `CAN` | | ### Example 4: Calculate holdings for all portfolios Holdings can be calculated in conjunction with the `Lusid.Portfolio.Holding` provider by joining on the portfolio scope and code. ```sql select grp.GroupCodePath, hold.* from Lusid.PortfolioGroup grp left join Lusid.Portfolio.Holding hold    on grp.PortfolioScope = hold.PortfolioScope    and grp.PortfolioCode = hold.PortfolioCode where grp.TopGroupScope = 'Groups-Example' and grp.TopGroupCode = 'Global' ```