TREATAS
A table's values applied as filters on other columns, as if the tables were related.
Group: Filter. Compatible with DAX.
Syntax
TREATAS ( <table_expression>, <column> [, <column>] … )
| Parameter | Type | Description |
|---|---|---|
table_expression | Table | A table whose values become the filter: one column for each column named. |
column | Column repeatable | A column of the model the values filter, in the order of the table's columns. |
Returns
Table. A filter on the named columns, holding the table's values.
Remarks
- It lets values filter a column they have no relationship with, as if there were one: a relationship for one calculation, without changing the model.
- Values the column does not hold are ignored: Stout matches no product.
- With several columns, each row of the table is a combination that must match as a whole.
- The table must have as many columns as are named; otherwise it is an error.
- Like other table filters, it replaces the filters on its columns. Wrap it in
KEEPFILTERSto narrow them instead.
Examples
Years for a table with no relationship
Sales has no relationship to Periods. TREATAS applies each year's months to Sales[Month].
EVALUATE
SUMMARIZECOLUMNS (
Periods[Year],
"No relationship", [Liters sold],
"Through TREATAS", CALCULATE ( [Liters sold], TREATAS ( VALUES ( Periods[Month] ), Sales[Month] ) )
)
ORDER BY Periods[Year]
| Periods[Year] | No relationship | Through TREATAS |
|---|---|---|
| 2024 | 1806463 | 586171 |
| 2025 | 1806463 | 603353 |
| 2026 | 1806463 | 523302 |
A list of values
EVALUATE
ROW (
"Pils and IPA",
CALCULATE (
[Liters sold],
TREATAS ( DATATABLE ( "Name", STRING, { { "Pils" }, { "IPA" }, { "Stout" } } ), Products[Product] )
)
)
| Pils and IPA |
|---|
| 1336210 |
Pairs of values
The margins of IPA from Oslo and Pils from Bergen; IPA from Bergen is not among the pairs.
EVALUATE
ROW (
"Two pairs",
CALCULATE (
SUM ( Production[Margin per liter] ),
TREATAS (
DATATABLE ( "Product", STRING, "Plant", STRING, { { "IPA", "Oslo" }, { "Pils", "Bergen" } } ),
Production[Product], Production[Plant]
)
)
)
| Two pairs |
|---|
| 31.5 |
Related functions
CALCULATE, KEEPFILTERS, USERELATIONSHIP, INTERSECT, DATATABLE.