Stop 08 · Filter Context & CALCULATEProjects · 1/1

Build a KPI Measures Library

Part of the Power BI Roadmap

In short

Teams don't hire people who write one clever measure. They hire people who build a clean, trustworthy set of measures that everyone can reuse. This project is that set, ready for your portfolio.

A project creating a well-organised set of 15-20 measures, such as sales, profit, margin, orders, customers, averages and shares of total, with consistent names, formats and display folders.

The jaadu, as a librarian on a rolling ladder, slides neatly labelled books into colour-coded shelves of a tidy school library.

Think of it like this

A well-kept school library

Every book has one place, a clear label and a catalogue entry, so any student finds it in a minute. A measures library is the same: each KPI written once, named clearly, formatted and filed in a folder, so every report uses the same numbers.

The big ideas

What you need to know

Build in layers

Derived measures reference base measures, so a definition changes in exactly one place.

Consistent names

Use a pattern like Total X, X %, Avg X. Avoid abbreviations people have to guess.

Display folders

Sales, Profit, Customers and Shares folders make a big library easy to browse.

Test cases

Keep a small test page with known numbers to recheck after any change.

How it works

Project plan

  1. 1

    List the questions

    Write down 15 to 20 questions a store manager in Lucknow or Kochi would ask: sales, profit, bills, customers, shares.

  2. 2

    Base measures

    Total Sales, Total Cost, Total Qty, Bills and Customers, each a simple aggregation.

  3. 3

    Derived measures

    Profit, Margin %, Avg Bill Value and Units per Bill, built only from base measures.

  4. 4

    Context measures

    % of Total, % of Category and a band with SWITCH, using CALCULATE.

  5. 5

    Organise

    A _Measures table, display folders, formats and a description on every measure.

  6. 6

    Test

    Check each measure by city and month, including blanks and totals.

See it in code

Walk through the code

dax
1-- Folder: Base2Total Sales = SUM ( Sales[Amount] )3Total Cost = SUM ( Sales[Cost] )4Bills = DISTINCTCOUNT ( Sales[BillNo] )5Customers = DISTINCTCOUNTNOBLANK ( Sales[CustomerKey] )6 7-- Folder: Profit8Gross Profit = [Total Sales] - [Total Cost]9Gross Margin % = DIVIDE ( [Gross Profit], [Total Sales] )10 11-- Folder: Averages12Avg Bill Value = DIVIDE ( [Total Sales], [Bills] )13Bills per Customer = DIVIDE ( [Bills], [Customers] )14 15-- Folder: Shares16% of Store Total =17DIVIDE ( [Total Sales], CALCULATE ( [Total Sales], REMOVEFILTERS ( Store ) ) )18 19-- Folder: Bands20Margin Band =21VAR m = [Gross Margin %]22RETURN SWITCH ( TRUE (), ISBLANK ( m ), BLANK (), m >= 0.3, "Excellent", m >= 0.15, "Healthy", "Thin" )

1/5Base measures are the only place raw columns are aggregated.

A starter library. Each line is a separate measure in Power BI. Grow it to 15-20 with the same pattern.

Save yourself the pain

Common mistakes

Oops

Writing SUM ( Sales[Amount] ) inside ten different measures.

Do this instead

Write Total Sales once and reference it everywhere. Changes then happen in one place.

Oops

Leaving every measure with the default format.

Do this instead

Set currency, percentage or whole-number formats on the measure itself so every visual shows it the same way.

Your mission

Ship the library

~90 min

Quick check

Why should Gross Profit be written as [Total Sales] - [Total Cost] rather than SUM ( Sales[Amount] ) - SUM ( Sales[Cost] )?

Go deeper

  1. 1Group measures into folders like Sales, Customers and Ratios.
  2. 2Add a description to each measure in the Properties pane.
  3. 3Test every measure in a matrix against known totals.

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