Power BI How-To / Customer Segmentation

How to Build an RFM Analysis in Power BI to Segment Customers

A Power BI RFM analysis scores every customer on recency, frequency and monetary value, then maps those scores to named segments such as Champions, At risk and Lost. Unlike a cohort analysis, which groups customers by the month they first bought, RFM looks only at what each customer is doing now. This guide builds it from a plain orders table: four calculated columns, RANKX scoring, one segment rule and a matrix that shows who is slipping away.

The short version

Three numbers per customer, one segment

Recency

Days from the customer’s last order to a fixed as-of date. Fewer days is better, so the ranking runs the opposite way to the other two.

Frequency

Distinct orders per customer. Count order IDs, not rows, or a five-line order counts as five visits.

Monetary

Total net spend per customer, after refunds. It sorts customers inside each segment so the most valuable ones get attention first.

What does an RFM analysis tell you about customers?

RFM scores every customer on three behaviors: recency, how many days since their last order; frequency, how many orders they have placed; and monetary value, how much they have spent. Each gets a score from 1 to 5, and the combination sorts customers into segments you can act on, from champions to the ones slipping away.

The value is in the action, not the score. A customer who ordered seven times but not for five months needs a different email from a customer who ordered once last week, even if both spent about the same. A total-sales report treats them as equals; RFM separates them. It needs nothing more than order history, which is why it is one of the first customer views we add to ecommerce and retail models.

What data does an RFM model need?

One orders table with a customer ID, an order ID, an order date and an order amount, plus a customers table with one row per buyer related one-to-many to orders. That is all. Shopify, WooCommerce, Stripe, QuickBooks and a SQL order history all export enough to build it.

Two data problems decide whether the result can be trusted. First, the customer key: if guest checkouts create a new customer ID on every order, a loyal buyer shows up as several one-time buyers and frequency collapses. Deduplicate on a normalized email address in Power Query or at the source before scoring. Second, refunds and cancelled orders: net them out of the amount, and drop fully cancelled orders, so a refund does not count as a visit. Keep only customers who have placed at least one order in the customers table, or filter them in Power Query, because a customer with no orders has no recency to score.

How do you calculate recency, frequency and monetary value in DAX?

Add four calculated columns to the customers table. Last Order Date, Frequency and Monetary use CALCULATE so each row sees only that customer’s orders, and Recency Days counts the days from the last order to a fixed as-of date. Columns are right here because the values describe each customer at refresh.

  1. Last Order Date = CALCULATE( MAX( Orders[OrderDate] ) )
  2. Recency Days = DATEDIFF( Customers[Last Order Date], MAX( Orders[OrderDate] ), DAY )
  3. Frequency = CALCULATE( DISTINCTCOUNT( Orders[OrderID] ) )
  4. Monetary = ROUND( CALCULATE( SUM( Orders[Amount] ) ), 2 )

CALCULATE turns the current customer row into a filter (context transition), so MAX, DISTINCTCOUNT and SUM only see that customer’s orders. In the Recency Days column the bare MAX( Orders[OrderDate] ) has no filter on it, so it returns the latest order date in the whole table. That is the as-of date: the last day you have data for, rather than TODAY(), which would make everyone look less recent whenever the source extract lags behind. Frequency uses DISTINCTCOUNT on the order ID because most order exports have one row per line item.

How do you turn raw values into 1-to-5 scores?

Rank each customer with RANKX, then cut the rank into five equal bands. Recency ranks ascending, so the most recent buyer scores 5; frequency and monetary rank descending, so the biggest spenders score 5. Customers with identical values share a rank and therefore share a score, which keeps the bands honest.

  1. R Score = VAR Rnk = RANKX( Customers, Customers[Recency Days], , ASC ) VAR N = COUNTROWS( Customers ) RETURN 5 - INT( ( Rnk - 1 ) * 5 / N )
  2. M Score = VAR Rnk = RANKX( Customers, Customers[Monetary], , DESC ) VAR N = COUNTROWS( Customers ) RETURN 5 - INT( ( Rnk - 1 ) * 5 / N )
  3. F Score = SWITCH( TRUE(), Customers[Frequency] >= 10, 5, Customers[Frequency] >= 5, 4, Customers[Frequency] >= 3, 3, Customers[Frequency] = 2, 2, 1 )

Rank 1 lands in band 5 and the last rank lands in band 1, with the rest spread evenly between. Frequency is the exception, and the reason is ties. In many stores a large share of customers have ordered exactly once. They all tie on the same rank, and that rank sits partway down the list, so a quintile formula hands every one-time buyer a middle score instead of a 1. Fixed thresholds avoid that; the cut-offs above are an example to agree with your marketing team, not a standard. Monetary is rounded because RANKX compares values exactly, and Microsoft’s RANKX function reference (opens in new tab) warns that Decimal Number columns can rank unexpectedly; rounding, or a Fixed Decimal Number data type, avoids it.

Two ways to score each RFM dimension, and when each one fits.
Approach How it works Best for Watch out for
Quintile rank (RANKX) Ranks every customer and cuts the list into five equal-sized bands Recency and monetary value, which take many distinct values Large ties push a whole block into one band; bands move as the customer base grows
Fixed thresholds (SWITCH) Business-agreed cut-offs, such as 10 or more orders scoring 5 Frequency, where most values are small whole numbers Cut-offs need revisiting if order patterns change; document them on the report

How do you map the scores to named segments?

Combine the recency and frequency scores in a SWITCH(TRUE()) column that returns a segment name. Recency and frequency carry the story: recent and frequent buyers are champions, frequent buyers who stopped are at risk. Keep monetary as a sort order within each segment, so the most valuable at-risk customers rise to the top.

Segment = VAR R = Customers[R Score] VAR F = Customers[F Score] RETURN SWITCH( TRUE(), R >= 4 && F >= 4, "Champions", R >= 3 && F >= 3, "Loyal", R >= 4, "New or promising", R = 3, "Needs attention", F >= 3, "At risk", "Lost" )

SWITCH returns the first condition that is true, so the order of the lines is the rule. Every one of the 25 recency and frequency combinations lands in exactly one segment:

The six segments the SWITCH rule returns, the score ranges behind each, and the usual next step.
Segment R score F score What it means Typical action
Champions 4–5 4–5 Bought recently and buy often Early access and referrals, not discounts
Loyal 3–5 3–5 (not Champions) Regular buyers, still active Cross-sell and keep them engaged
New or promising 4–5 1–2 Recent first or second order Onboarding and a reason for a second order
Needs attention 3 1–2 Few orders, cooling off A timely reminder before they lapse
At risk 1–2 3–5 Used to buy often, has gone quiet Personal win-back, highest Monetary first
Lost 1–2 1–2 Few orders, long ago Low-cost reactivation or leave alone

What does a worked RFM table look like?

Below are six illustrative customers on sample data, scored against a larger customer base. Recency is days since the last order, frequency is the order count with the fixed thresholds above, and spend is in sample units. Reading the segment column against the raw values shows why two customers with similar spend can need opposite actions.

Illustrative sample data, not client results: raw RFM values, scores and the segment each customer lands in.
Customer Recency (days) Orders Spend (sample units) R / F / M Segment
Customer A6143,9005 / 5 / 5Champions
Customer B2161,2504 / 4 / 4Champions
Customer C4849803 / 3 / 3Loyal
Customer D121855 / 1 / 1New or promising
Customer E16071,3002 / 4 / 4At risk
Customer F4101401 / 1 / 1Lost

Customers B and E have almost the same spend and the same frequency score. A sales-by-customer table would list them side by side. RFM puts B in Champions and E in At risk, because E has not ordered for 160 days. E is exactly the customer the win-back list exists for: a proven, valuable buyer who has gone quiet. Customer D shows why monetary should not drive the segment on its own; a low score for a first order says nothing yet about how valuable D will become.

How do you show who is slipping away?

Put R Score on rows and F Score on columns of a matrix with a customer count, sorted so high scores sit top and right, then color it with conditional formatting. The top-right corner holds champions; the bottom-right holds frequent buyers who have gone quiet. Pair it with a table of at-risk customers sorted by Monetary.

The customer count is one measure, Customers = COUNTROWS( Customers ), and Microsoft’s guide to conditional table formatting in Power BI (opens in new tab) covers the background color scale. Add Segment as a slicer, and the at-risk table becomes the working list: customer, last order date, frequency and monetary, sorted by monetary so the most valuable lapsed buyers come first. Because the segment is a calculated column, it reflects the last refresh. To see customers moving from Loyal into At risk over time, save a monthly snapshot of each customer’s scores in your warehouse or a dataflow and compare two snapshot dates.

How is RFM different from cohort analysis and lifetime value?

A cohort analysis groups customers by the month of their first order and tracks how each group decays. RFM ignores when customers arrived and scores what each one is doing now. Lifetime value estimates what a customer will be worth in the future; Monetary is only what they have spent so far.

The three answer different questions, and they share the same orders table and customer key. Use our Power BI cohort retention guide to see whether newer customers are coming back better or worse than older ones; use RFM to decide who to contact this week. Monetary is a fair stand-in for value when you are prioritizing a win-back list, but do not label it lifetime value on a report. A forward-looking lifetime value needs assumptions about margin and future retention, and those assumptions belong in a separate, documented model.

When should a senior engineer build it for you?

Bring in help when segments will drive marketing spend and the order data is messy: several stores, guest checkouts, refunds, or customer IDs that changed in a platform migration. The DAX on this page is short; cleaning the customer key and agreeing the scoring rules with marketing is where most of the work sits.

Power BI Flex Support is prepaid, senior-led Power BI hours that never expire, with no contracts and no project minimums. Blocks are Starter $2,500, Growth $4,600 and Power $8,000, and hourly work starts from $100. You send the request, we reply with a scope and an hours estimate before any work, hours are deducted only for work you approve, and most tasks land 3–5 business days after approval. For stores, RFM segments sit naturally alongside the order and product views in a Shopify Power BI dashboard or a wider ecommerce brand dashboard. Contact is through the form on this site.

FAQ

Frequently asked questions

Use the latest order date in the data, not TODAY. If the source extract lags a week behind, TODAY makes every customer look a week less recent than they really are, and the recency scores shift for no business reason. For a month-end report, use the last day of that month instead.

Quintiles suit recency and monetary value, which spread across many distinct values. Frequency usually needs fixed thresholds, because so many customers order only once that they tie on one rank and land in a middle band. Agree the thresholds with whoever owns the marketing plan and write them on the report.

Not as calculated columns. Columns are computed at refresh and ignore slicers, so a customer keeps the same segment whatever the page is filtered to. That is usually what you want. If each region must be scored against its own customers, rewrite the scores as measures that rank over ALLSELECTED, and expect slower visuals.

Save a snapshot. Calculated columns are overwritten at every refresh, so the segment from last month disappears. Append the customer ID, the three scores and the segment to a snapshot table once a month, in your warehouse or a dataflow, then compare two snapshot dates to list customers who moved from Champions or Loyal into At risk.

Yes. A senior, US-based, Microsoft-certified engineer can build the RFM model, segments and matrix on your own order data from prepaid Flex hours that never expire. Blocks are Starter $2,500, Growth $4,600 and Power $8,000, with hourly work from $100. We quote the hours before starting, and most tasks land in 3 to 5 business days after approval.

Try us risk-free for 4 hours

If you’re unhappy within the first 4 hours of your block, we’ll refund you in full — no questions asked. Hours are deducted only for work you’ve reviewed and approved, and they never expire.

Want a segment list your marketing team can act on?

Bring your order data to a free demo. We check the customer key, agree the scoring rules with you, and build the segments and win-back list on prepaid hours that never expire. Most tasks land in 3–5 business days.

Scope approved before any hours are used · Hours never expire

Book a free demo

See what your Power BI reporting would take

Tell us the task. We reply within one business day, and you get a scope estimate and the hours needed before any work begins.

Step 1 of 2: What do you need?

How can we help? Pick one

Tap to add, or type your own:

Step 2 of 2: Where should we reply?

Used only to contact you about this inquiry.

We reply within one business day. Scope approved before any hours are used. We don’t sell your information.

Tell us the task. We scope it, you approve, and a senior consultant delivers — typically in 3–5 business days. Prepaid hours that never expire.

  • Prepaid hours from $100/hour — and they never expire
  • Senior-led delivery — 20+ years on the Microsoft platform
  • Typical 3–5 business day turnaround
  • Full refund if you’re unhappy in your first 4 hours
Book my free demo