OpenBI Docs Buy

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>] … )
ParameterTypeDescription
table_expressionTableA table whose values become the filter: one column for each column named.
columnColumn
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 KEEPFILTERS to 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 relationshipThrough TREATAS
20241806463586171
20251806463603353
20261806463523302

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

CALCULATE, KEEPFILTERS, USERELATIONSHIP, INTERSECT, DATATABLE.

Last updated · OpenBI Studio 0.3.74