Stop 09 · Advanced DAX PatternsTopics · 8/10

Dynamic Segmentation (Customer Bands)

Part of the Power BI Roadmap

In short

Labelling customers Low, Medium or High in a calculated column freezes them forever. A Mumbai customer who is High for the year might be Low this month. Dynamic segmentation bands them by whatever filters are on right now.

Dynamic segmentation groups items into bands like Low, Medium and High spenders based on a measure, so the bands update when filters change instead of being fixed in a column.

The jaadu weighs cloth bundles on a big hanging scale and drops each one into a small, medium or large basket.

Think of it like this

Sorting laundry by weight

Every week the dhobi weighs each customer's bundle and puts it in the light, medium or heavy pile. Next week the same customer might land in a different pile. He doesn't paint the label on the customer, he weighs again. Dynamic bands do the same: measure first, then place.

Watch it happen

Placing customers into spend bands

Riya ₹3,200
0
Arjun ₹18,500
1
Kavya ₹41,000
2
Sameer ₹900
3
Neha ₹7,600
4

1/5The band table says Low is below ₹5,000, Medium is ₹5,000 to ₹25,000, High is ₹25,000 and above.

The big ideas

What you need to know

A disconnected band table

A small table with Band, Min Spend and Max Spend. It has no relationships and drives the rows of your visual.

Measure each customer

Iterate over customers, compute their spend in the current context, and keep those inside the band's limits.

Reacts to filters

Because spend is a measure, bands update with any slicer: date, region, category.

Bands must not overlap

Use >= Min and < Max so a customer at exactly ₹5,000 lands in one band only.

See it in code

Walk through the code

dax
1-- Band table (New table, no relationships)2Spend Band =3DATATABLE (4    "Band", STRING, "Min Spend", INTEGER, "Max Spend", INTEGER,5    { { "Low", 0, 5000 }, { "Medium", 5000, 25000 }, { "High", 25000, 999999999 } }6)7 8Customers in Band =9COUNTROWS (10    FILTER (11        VALUES ( Customer[CustomerID] ),12        VAR Spend = [Total Sales]13        RETURN Spend > 014            && Spend >= MIN ( 'Spend Band'[Min Spend] )15            && Spend < MAX ( 'Spend Band'[Max Spend] )16    )17)

1/4DATATABLE builds the three bands with their rupee limits.

Put 'Spend Band'[Band] on rows and Customers in Band as the value. Sort Band by Min Spend.

Save yourself the pain

Common mistakes

Oops

Creating the band as a calculated column in Customer from lifetime sales.

Do this instead

Calculated columns are computed at refresh and ignore slicers. Use a measure when bands must follow filters.

Oops

Relating the band table to Customer.

Do this instead

Keep it disconnected. The measure reads its limits with MIN and MAX in each visual row.

Your mission

Band your customers

~25 min

Quick check

Why use a measure instead of a calculated column for customer bands?

Go deeper

  1. 1Create a small disconnected Bands table with Min and Max values.
  2. 2Write a measure that counts customers whose sales fall inside each band.
  3. 3Change the date slicer and watch customers move between bands.

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