Stop 09 · Advanced DAX PatternsTopics · 7/10

Virtual Relationships with TREATAS

Part of the Power BI Roadmap

In short

The sales team sends monthly targets by category in a separate sheet. It has no ProductID, so you can't relate it to Product directly. TREATAS links them on the fly, only inside the measure that needs it.

TREATAS applies the values of one table as filters on columns of another table, which creates a relationship only for that calculation, for example linking a targets table to a product dimension.

The jaadu stands between two tables of people, catching coloured paper planes from one side and throwing matching planes to the other.

Think of it like this

The translator in the meeting

A Chennai team speaks Tamil, a Kolkata team speaks Bengali, and there's no common language in the room. A translator listens to one side and passes the same meaning to the other, but only during this meeting. TREATAS takes the categories selected in Product and passes them across to the Targets table as if a relationship existed.

Watch it happen

Passing a filter across without a relationship

Visual row
Product
TREATAS
Targets

Category = Snacks

1/4The matrix row filters the Product table to Snacks.

The big ideas

What you need to know

No model relationship

Targets sits on its own. The link exists only while the measure runs.

Filter values by name

TREATAS ( table_of_values, Target[Column] ) applies values as a filter, matching on the values themselves.

Multiple columns

Use one TREATAS per column, like Category and Month Start, to match targets at their own grain.

Faster than FILTER tricks

TREATAS is usually quicker and clearer than FILTER with CONTAINS or INTERSECT for the same job.

See it in code

Walk through the code

dax
1Total Target = SUM ( Targets[Target Amount] )2 3Target =4CALCULATE (5    [Total Target],6    TREATAS ( VALUES ( Product[Category] ), Targets[Category] ),7    TREATAS ( VALUES ( 'Date'[Month Start] ), Targets[Month Start] )8)9 10Sales vs Target % =11DIVIDE ( [Total Sales], [Target] )

1/4A plain sum. On its own it ignores Product and Date because Targets isn't related to them.

Targets keyed by Category and Month Start, filtered through Product and Date without any relationship.

Save yourself the pain

Common mistakes

Oops

Expecting the target to show by Product Name when targets exist only by Category.

Do this instead

TREATAS can only match columns the target table has. Show targets at category and month level, or allocate them down first.

Oops

Category spelled "Personal care" in Targets and "Personal Care" in Product.

Do this instead

Clean both sides in Power Query so the values match exactly, or rows silently get no target.

Your mission

Hook up a targets sheet

~25 min

Quick check

What does TREATAS ( VALUES ( Product[Category] ), Targets[Category] ) do?

Go deeper

  1. 1Filter a Targets table by the selected product categories using TREATAS.
  2. 2Compare it with creating a physical relationship.
  3. 3Use it when a physical relationship would cause ambiguity.

More topics at this stop

Stuck on this topic? Ask an Insider

Get 1:1 guidance from people who've walked this exact path — on the InsideEdge app.

Download
InsideEdge