Stop 08 · Filter Context & CALCULATETopics · 2/9

How Filters Flow Through Relationships

Part of the Power BI Roadmap

In short

You click "Snacks" on a Category slicer and the sales chart updates, even though the slicer is on a different table. That's a filter travelling along a relationship, and knowing its path explains a lot of odd numbers.

A filter on a dimension, like Product[Category] = "Snacks", travels along the relationship to the fact table, so every measure on Sales only sees snack rows. Filters do not flow back up a single-direction relationship.

The jaadu pours purple dye into a water tank on a hilltop and watches it flow down pipes into small houses in the village below.

Think of it like this

Water flowing downhill

Pour coloured water into a tank on a hill and it runs down the pipes into the village below. It doesn't run back up by itself. Filters behave the same way: from the dimension (the hill) down to the fact (the village), along the relationship pipes.

Watch it happen

A Snacks filter on its way

Product
Sales
Store

Category = Snacks

1/3The slicer filters Product to snack products, and the filter flows down the one-to-many relationship. Sales keeps only snack rows.

The big ideas

What you need to know

One side to many side

A filter on Product reaches Sales. A filter on Sales does not reach Product with single direction.

Dimensions don't filter each other

Product filters Sales, but Sales doesn't pass it on to Store. Two dimensions only meet in the fact.

Why slicers show everything

A Store slicer lists all stores even when you've picked Snacks, because Store isn't filtered.

Chains work downhill

Category to Product to Sales: a filter on a Category table flows all the way to Sales, one hop at a time.

See it in code

Walk through the code

dax
1Total Sales = SUM ( Sales[Amount] )2 3Stores = COUNTROWS ( Store )4 5Stores With Sales =6DISTINCTCOUNT ( Sales[StoreKey] )7 8Stores Selling =9COUNTROWS ( FILTER ( Store, NOT ISBLANK ( [Total Sales] ) ) )

1/4Sales is downhill from Product, so it's filtered to snacks.

With a Category slicer set to Snacks: Total Sales shows snack sales, Stores shows every store, and the last two show only stores that sold snacks.

Save yourself the pain

Common mistakes

Oops

Expecting COUNTROWS ( Customer ) to drop when you filter a product.

Do this instead

Product filters Sales, not Customer. Count keys in Sales, or test the measure per customer with FILTER.

Oops

Turning relationships to Both so dimensions filter each other everywhere.

Do this instead

Keep single direction and write measures that go through the fact, as above.

Your mission

Trace a filter

~20 min

Quick check

With single-direction relationships Product to Sales and Customer to Sales, does a Product filter reduce COUNTROWS ( Customer )?

Go deeper

  1. 1Filter by a Product column and watch a Sales measure change.
  2. 2Filter by a Sales column and see that a COUNTROWS ( Product ) measure does not.
  3. 3Draw the arrows of your model on paper and trace one filter.

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