Tables.GetRelationships

Table

Returns the relationships among a set of tables structured like a navigation table.

Examples on this page use shared sample tables. View them to understand the input data before reading the examples below.

Syntax

Tables.GetRelationships(tables as table, optional dataColumn as nullable text) as table

Parameters

NameTypeRequiredDescription
tablestableYesA set of tables with a navigation-table-like structure.
dataColumntextNoThe name of the column that contains the actual data tables. Defaults to the standard navigation table data column.

Return Value

tableA table describing the relationships between the input tables.

Remarks

Tables.GetRelationships inspects a set of tables (typically a navigation table returned by a data source connector) and returns a table describing the relationships between them. The tables parameter is expected to have the structure of a navigation table — the kind of table returned by functions like Sql.Database, AnalysisServices.Database, or Excel.Workbook.

The optional dataColumn parameter specifies which column in the navigation table holds the actual table values. If omitted, the function uses the default navigation table data column.

This function is most useful when working programmatically with relational data sources where you need to discover foreign key relationships between tables — for example, when building a data model dynamically or validating relationship integrity.

Examples

Example 1: Discover relationships from a SQL Server database

let
    NavTable = Sql.Database("localhost", "AdventureWorks"),
    Relationships = Tables.GetRelationships(NavTable)
in
    Relationships

Compatibility

Power BI Desktop Power BI Service Excel Desktop Excel Online Dataflows Fabric Notebooks