Format Strings
Infohub format strings are .NET format strings — including the three-section trick that turns a number into Pass or Fail.
A measure's Format controls how its values are displayed, everywhere — charts, tables, widgets, forms, reports, notifications. It does not change the stored value, only its presentation.
Infohub passes the format string straight to .NET's number formatting, which means the entire standard .NET numeric format string specification is available to you, including some patterns that are far more useful than they first appear.
The formats you will use most#
| Format | 1234.567 displays as |
Use for |
|---|---|---|
0 |
1235 |
Counts, whole units |
0.0 |
1234.6 |
One decimal place |
0.00 |
1234.57 |
Two decimal places |
#,##0 |
1,235 |
Large counts with thousands separators |
#,##0.00 |
1,234.57 |
Money, tonnages |
0.0 '%' |
1234.6 % |
A value already expressed as a percentage |
0.0% |
123456.7% |
A ratio — .NET multiplies by 100 |
% multiplies by 100. In .NET format strings, % is not a decoration — it scales the number. If your measure already holds 92.4 meaning 92.4%, then 0.0% displays 9240.0%. Either store the ratio (0.924) and format with 0.0%, or store the percentage (92.4) and use a quoted literal such as 0.0 '%'. Pick one convention for the whole model; mixing them is a reliable source of wrong dashboards.
0 and # are not the same#
This is the distinction that trips people up.
0is a digit placeholder that forces a digit.0.00renders5as5.00.#is a digit placeholder that is omitted when not needed.#.##renders5as5and5.5as5.5.
For operational reporting, prefer 0. A column of 5.00, 12.30, 7.85 reads far better than 5, 12.3, 7.85, because the decimal points line up and the eye can scan it. Use # only where trailing zeros would be actively misleading.
The three-section pattern#
A .NET format string can carry up to three sections separated by semicolons:
positive ; negative ; zero
Each section formats its own case. This is ordinary number formatting:
#,##0.0;(#,##0.0);—
That renders 1234.5 as 1,234.5, -1234.5 as (1,234.5) in accounting style, and 0 as an em dash so empty cells do not clutter a table.
The powerful use is replacing numbers with words entirely. Because a section can be a quoted literal, a numeric measure can display as text:
| Format | Positive | Negative | Zero |
|---|---|---|---|
'Pass';'Fail';'Fail' |
Pass | Fail | Fail |
'Running';'Fault';'Stopped' |
Running | Fault | Stopped |
'Above';'Below';'On target' |
Above | Below | On target |
'Yes';'No';'No' |
Yes | No | No |
A calculated measure returning 1 or 0 then displays as Pass or Fail on a widget, with no chart configuration and no enumeration required. This is the cheapest way to put a status indicator on a dashboard.
Combine it with a limit for colour. The format supplies the word; a measure limit supplies the colour. A widget showing a green Pass or a red Fail is a format string and a limit, nothing more.
Variance formats#
For measures that can go either way, showing the sign explicitly removes ambiguity:
+#,##0.0;-#,##0.0;0.0
+12.5, -12.5, 0.0. On a variance-to-target column this is much clearer than relying on the reader to notice a minus sign.
Scaling in the format string#
A trailing comma in a .NET format string divides by a thousand, which lets you display large numbers compactly without changing the stored value or the unit:
| Format | 1234567 displays as |
|---|---|
#,##0 |
1,234,567 |
#,##0, |
1,235 |
#,##0,, |
1 |
Use this sparingly, and only where the unit label makes the scale unambiguous. Displaying kWh divided by a thousand while the measure is still labelled kWh is exactly how a report ends up out by three orders of magnitude. If you scale in the format, say so in the unit.
Choosing decimal places#
Match the precision to the instrument and the audience, not to the number of digits the calculation produced.
| Quantity | Typical format | Why |
|---|---|---|
| Temperature | 0.0 |
Instruments are rarely better than 0.1 °C |
| Pressure | 0.00 |
Small absolute values, precision matters |
| Infohub rate | 0.0 |
|
| Daily production count | #,##0 |
Fractional bottles do not exist |
| Monthly tonnage | #,##0.0 |
|
| Percentage | 0.0 |
A second decimal implies precision you do not have |
| Money | #,##0.00 |
Convention |
| Efficiency ratio | 0.000 |
Where small differences are meaningful |
Displaying 87.6543210% does not make a number more accurate; it makes it less readable and implies confidence that is not there.
Format inheritance and aggregation#
A format is a property of each measure, and it is not inherited down an aggregation chain. An hourly measure formatted 0.0 and a daily measure created afterwards may well default to something different.
Set the format when you create a measure. In practice a chain often wants different formats at different levels: hourly flow at 0.0, daily total at #,##0, monthly total at #,##0 with a scaled unit. Deliberate variation is fine; accidental variation looks like carelessness on a dashboard.
Templates keep this consistent across instances, which is one of their quieter benefits.
Common mistakes#
| Mistake | Result |
|---|---|
0.0% on a value already in percent |
Displays 100× too large |
# where 0 was meant |
Ragged decimal alignment in tables |
| No format set | Full floating-point precision on screen |
| Too many decimals | Unreadable, implies false precision |
| Scaling with a comma but not adjusting the unit | Numbers wrong by 1,000× to any reader |
| Formatting inside the calculation expression | Expression returns a double?; formatting belongs on the measure |
Keep formatting out of expressions. It is tempting to write .ToString("0.0") inside a calculation. Don't — a calculation must evaluate to a double?, and formatting there breaks the contract, defeats the measure's own format, and makes the value unusable to charts and consumers that expect a number.
Testing a format#
Check it against the awkward cases, not the typical one:
- A normal value.
- Zero.
- A negative value, if the measure can go negative.
- A very large value — does the thousands separator appear where you expect?
- A very small value — does it round to zero and look broken?
Formats are cheap to change and easy to get subtly wrong, so five seconds of checking is worth it.