Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Applies to:
Calculated column
Calculated table
Measure
Visual calculation
Returns a reference to the table associated with a specified column, measure, or calendar.
Syntax
TABLEOF ( <myColumnRef> )
TABLEOF ( <measureName> )
TABLEOF ( <myCalendar> )
Parameters
| Term | Definition |
|---|---|
reference |
A column, measure, or calendar reference. |
Return value
A table reference.
Remarks
- The
TABLEOFfunction returns a table reference, not the table data itself. - When passed a column name, it returns the table that contains that column.
- When passed a measure name, it returns the table where that measure is defined.
- When passed a calendar reference, it returns the table associated with that calendar.
- This function is useful in scenarios where you need to dynamically determine which table a column or measure belongs to.
TABLEOFdoes not resolve columns from row context; it only resolves columns from the current filter context (base table).- This function is not supported for use in DirectQuery mode when used in calculated columns or row-level security (RLS) rules.
Example 1 - Using TABLEOF with a column
EVALUATE
ROW ( "RowCount", COUNTROWS ( TABLEOF ( 'Customer'[Customer ID] ) ) )
Returns:
| RowCount |
|---|
| 18485 |
Example 2 - Using TABLEOF with a measure
DEFINE
MEASURE Sales[Projected Sales] =
SUM ( 'Sales'[Sales Amount] ) * 1.06
EVALUATE
ROW (
"Total Projected Sales", ROUND ( SUMX ( TABLEOF ( [Projected Sales] ), [Projected Sales] ), 2 )
)
Returns:
| Total Projected Sales |
|---|
| 116397830.65 |
Example 3 - Using TABLEOF in a user-defined function
DEFINE
FUNCTION GetTableRowCount = (
columnRef : ANYREF
) =>
COUNTROWS ( TABLEOF ( columnRef ) )
EVALUATE
ROW (
"ResellerCount", GetTableRowCount ( 'Reseller'[Reseller ID] ),
"CustomerCount", GetTableRowCount ( 'Customer'[Customer ID] )
)
Returns:
| ResellerCount | CustomerCount |
|---|---|
| 702 | 18485 |