Sub topic 9
Naming, formatting, and organizing measures
You can write a correct measure and still make a model hard to use. A report author who sees Measure 1, Measure 2, and a long unsorted list of fields cannot tell which one to drag onto a visual. This chapter covers the habits that keep measures findable and readable: names, format settings, display folders, descriptions, and comments.
It assumes you have already created Total Sales, Order Lines, and Average Sales per Order Line from the earlier chapters. It also assumes you can open Model view in Power BI Desktop.
Why presentation matters for measures
A measure has no column of values to inspect. Users judge it by its name, its number format, and where it sits in the Fields pane. If any of these is unclear, people pick the wrong field or misread the number. For example, a ratio shown as 0.0832 looks like a bug, while 8.3% does not.
Four properties carry most of this work:
- The name, which you type before the equals sign.
- The format, which controls how the number is displayed.
- The home table and display folder, which control where the measure appears.
- The description, which appears as a tooltip when someone hovers over the field.
None of these properties changes the value the measure calculates. They change how people find it and read it.
Naming measures
A measure name is the text before the = in the formula bar. You reference it elsewhere by wrapping it in square brackets, as in [Total Sales].
Good names follow a few rules:
- Use business language.
Total Salesis better thanSumSalesAmt. Report users read these names directly in slicers, tooltips, and visual titles. - Describe what the number is.
Order Linessays what is being counted.Count1does not. - Keep the unit or scope visible when it matters.
Average Sales per Order Linetells the reader both the aggregation and the grain. - Pick one casing style and keep it. Title Case with spaces is common in Power BI because the name appears as written in the report.
- Avoid names that look like columns. If a measure and a column share a name in different tables, report authors cannot easily tell them apart in the Fields pane.
Measure names must be unique across the whole model, not just within a table. A measure also cannot share a name with a column in its own table. If you try, Power BI Desktop shows an error.
A consistent convention for variants helps too. If you create several versions of one measure, put the distinguishing part at the end, so related names sort together:
Average Sales per Order Line = DIVIDE([Total Sales], [Order Lines])
Average Sales per Order Line (0 if none) = DIVIDE([Total Sales], [Order Lines], 0)Both names start with the same words, so they sit next to each other in an alphabetical list.
Renaming safely
You can rename a measure by double-clicking it in the Fields pane or by editing the name in the formula bar. Power BI Desktop updates other measures that reference it and updates visuals in the same report. Check anything outside the model, such as Excel workbooks connected with Analyze in Excel, or other reports built on the same semantic model. Those consumers can break when a name changes.
Formatting measures
Every measure has a data type and a format. Select the measure in the Fields pane and open the Measure tools ribbon. There you can choose a format such as Whole number, Decimal number, Currency, or Percentage. You can also set the number of decimal places and turn the thousands separator on or off.
Choose the format to match what the number means:
| Measure | Meaning | Suitable format |
|---|---|---|
| `Total Sales` | Money | Currency, 0 or 2 decimals |
| `Order Lines` | A count | Whole number with thousands separator |
| `Average Sales per Order Line` | Money per row | Currency, 2 decimals |
| A share of total | A fraction | Percentage, 1 decimal |
Format is stored on the measure, so every visual that uses it inherits the setting. You set it once, and you do not need to format each visual by hand. A visual can still override it.
Format strings
Behind the ribbon buttons, Power BI stores a format string. Examples are #,0 for a whole number with thousands separators, #,0.00 for two decimals, and 0.0% for a percentage with one decimal. In Model view, select the measure and edit the Format string under Formatting in the Properties pane to enter a custom one.
The FORMAT function trap
DAX also has a FORMAT function. It returns text, not a number:
Total Sales Text = FORMAT([Total Sales], "#,0.00")This measure looks fine in a card, but it is a string. You cannot sum it, sort it numerically, use it in a chart axis as a value, or combine it in a ratio. Use the measure's format setting for display, and reserve FORMAT for cases where you truly need text, such as building a label.
Organizing measures with home tables and display folders
A measure must live in some table in the model, called its home table. The home table has no effect on the calculation, because a measure's formula decides which columns it reads. The home table only controls where the measure appears in the Fields pane.
Two common approaches work:
- Keep each measure on the table it is about.
Total SalesandOrder Linessit onSales. This is simple, and the measure appears next to the columns it uses. - Create a dedicated measures table. You make a table with no data, such as one named
_Measures, and move all measures there. The leading underscore sorts it to the top of the Fields pane. Power BI Desktop shows a table that holds only measures with a calculator icon.
To move a measure, select it, and on the Measure tools ribbon change Home table. In Model view you can do the same in the Properties pane.
A separate measures table suits larger models, since report authors find every measure in one place. The cost is that measures no longer sit beside their source columns. For a model with one fact table and a handful of measures, leaving them on Sales is fine.
Display folders
A display folder groups fields inside a table in the Fields pane. Open Model view, select one or more measures (hold Ctrl to select several), and type a name in the Display folder box of the Properties pane.
Folders can nest. Use a backslash to separate levels:
Sales\Revenue
Sales\Counts
Sales\RatiosThis puts the folder Revenue, Counts, or Ratios inside a parent folder named Sales. A reasonable grouping for the measures so far is:
| Display folder | Measures |
|---|---|
| `Sales\Revenue` | `Total Sales` |
| `Sales\Counts` | `Order Lines`, `Large Order Lines` |
| `Sales\Ratios` | `Average Sales per Order Line`, `Average Sales per Order Line (0 if none)` |
Display folders affect only the Fields pane. They do not change how you write DAX, and [Total Sales] is referenced the same way wherever it lives.
Descriptions and comments
There are two places to record what a measure means, and they serve different readers.
The description is for report authors. In Model view, select the measure and type text in the Description box. It appears as a tooltip when someone hovers over the field in the Fields pane. A good description states what is counted or summed and any rule that applies. For Order Lines, you might write: "Number of rows in Sales. Each row is one order line."
Comments are for people who edit the formula. DAX supports two styles:
// Total of SalesAmount in the current filter context.
Total Sales = SUM(Sales[SalesAmount])/* Returns BLANK when there are no order lines,
so empty groups stay out of the visual. */
Average Sales per Order Line = DIVIDE([Total Sales], [Order Lines])A // comment runs to the end of the line. A /* ... */ comment can span several lines. In the formula bar, press Shift+Enter to start a new line, because Enter alone commits the formula.
Comments should explain why, not repeat what the code says. A comment above SUM(Sales[SalesAmount]) that reads "sums sales amount" adds nothing. A comment that says "excludes tax; tax is stored in a separate column" is useful.
Hiding what authors should not use
Once a model has measures, the raw numeric columns can invite mistakes. If report authors drag Sales[SalesAmount] into a visual, Power BI creates an implicit aggregation that bypasses your measure, which the next chapter covers. In Model view you can set a column to hidden so only your explicit measures appear. Hiding does not delete the column, and measures such as SUM(Sales[SalesAmount]) still use it.
A worked tidy-up
Suppose a model has these measures, all on the Sales table with default formats:
Measure = SUM(Sales[SalesAmount])
Measure 2 = COUNTROWS(Sales)
Measure 3 = DIVIDE([Measure], [Measure 2])The formulas are correct, but the model is hard to use. A tidy-up goes in this order:
- Rename the measures to
Total Sales,Order Lines, andAverage Sales per Order Line. Power BI Desktop rewrites the references inMeasure 3for you. - Set
Total SalesandAverage Sales per Order Lineto Currency with 2 decimals, andOrder Linesto Whole number with a thousands separator. - Assign display folders such as
Sales\Revenue,Sales\Counts, andSales\Ratios. - Add a description to each measure.
- Hide
Sales[SalesAmount]from Report view.
After step 1, the formulas read:
Total Sales = SUM(Sales[SalesAmount])
Order Lines = COUNTROWS(Sales)
Average Sales per Order Line = DIVIDE([Total Sales], [Order Lines])Each formula now describes itself, and the later measure explains what it divides.
Common mistakes
- Leaving default names.
Measure,Measure 2, and so on tell nobody anything and are easy to confuse after a few weeks. - Using FORMAT for display. The result is text, so downstream numeric use breaks.
- Formatting every visual by hand. Set the format on the measure, so every visual inherits it.
- Putting measures on an unrelated table. This is harmless to the calculation but confusing to browse. Choose either source tables or one measures table and apply it consistently.
- Renaming published measures casually. Reports and Excel files outside your file may stop working.
- Skipping descriptions on ratios. A ratio's meaning is least obvious, so it benefits most from a sentence of explanation.
Exercise
A colleague writes Sales Display = FORMAT([Total Sales], "$#,0.00") so the number shows a dollar sign in a card. Then they try to use Sales Display in a chart's value field and get unexpected results. What is the cause, and what is the better fix?
Show answer
FORMAT returns text, so Sales Display is a string and cannot be aggregated or plotted as a number. The better fix is to keep Total Sales numeric and set its format to Currency (or a format string such as $#,0.00) in the Measure tools ribbon or in the Properties pane of Model view.
Exercise
You have the measures Total Sales, Order Lines, Large Order Lines, and Average Sales per Order Line. Propose a display folder for each using nested folders under Sales, and state one thing display folders do not change.
Show answer
One option is Sales\Revenue for Total Sales, Sales\Counts for Order Lines and Large Order Lines, and Sales\Ratios for Average Sales per Order Line. Display folders only change how fields are grouped in the Fields pane. They do not change the formula, how other measures reference the measure, or the value it returns.