Use custom format strings in Power BI Desktop

APPLIES TO: Power BI Desktop  Power BI service

With custom format strings in Power BI Desktop, you can customize how fields appear in visuals and make sure your reports look just the way you want them to.

Screenshot of Power BI desktop in Modeling view, highlighting Custom in the Format dropdown menu.

How to use custom format strings

To create custom format strings, select the field in the Modeling view, and then select the dropdown arrow under Format in the Properties pane.

Screenshot of the Properties pane, highlighting the Format menu.

Once you've selected Custom from the Format dropdown menu, choose from a list of commonly used format strings.

Screenshot of the Formatting menu, highlighting Custom.

Supported custom format syntax

Custom format strings follow the VBA style syntax, common to Excel and other Microsoft products, but they don't support all syntax used in other products.

The following tables define the syntax supported in Power BI.

Supported Date symbols

Symbol Range
d 1-31 (Day of month, with no leading zero)
dd 01-31 (Day of month, with a leading zero)
m 1-12 (Month of year, with no leading zero, starting with January = 1)
mm 01-12 (Month of year, with a leading zero, starting with January = 01)
mmm Displays abbreviated month names (Hijri month names have no abbreviations)
mmmm Displays full month names
yy 00-99 (Last two digits of year)
yyyy 100-9999 (Three- or four-digit year)

Supported Time symbols

Symbol Range
h 0-23 (1-12 with "AM" or "PM" appended) (Hour of day, with no leading zero)
hh 00-23 (01-12 with "AM" or "PM" appended) (Hour of day, with a leading zero)
n 0-59 (Minute of hour, with no leading zero)
nn 00-59 (Minute of hour, with a leading zero)
m 0-59 (Minute of hour, with no leading zero). Only if preceded by h or hh
mm 00-59 (Minute of hour, with a leading zero). Only if preceded by h or hh
s 0-59 (Second of minute, with no leading zero)
ss 00-59 (Second of minute, with a leading zero)

You can see an example of how to format custom value strings.

A user-defined format expression for numbers can have one to three sections separated by semicolons. If you include semicolons with nothing between them, the missing section won't display (it will be ""). If you don't specify the semicolon, it uses the positive format.

Here are examples of different formats for different value strings:

Values Format String Format String Format String Format String
0.00;-0.0;"Zero" 0.00;; 0.00;-0.0; 0.00;
-1.234 -1.2 "" -1.2 ""
0 "Zero" "" "" 0.00
1.234 1.23 1.23 1.23 1.23

The following table identifies the predefined named date and time formats:

Format name Description
General Date Display a date and time, for example, 4/3/93 05:34 PM. If there's no fractional part, display only a date, for example, 4/3/93. If there's no integer part, display time only, for example, 05:34 PM. Date display is determined by your system settings.
Long Date Display a date according to your system's long date format.
Short Date Display a date using your system's short date format.
Long Time Display a time using your system's long time format; includes hours, minutes, seconds.
Short Time Display a time using the 24-hour format, for example, 17:45.

Named numeric formats

The following table identifies the predefined named numeric formats:

Format name Description
General Number Display number with no thousand separator.
Currency Display number with a thousand separator. Display two digits to the right of the decimal separator. Output is based on system locale settings.
Fixed Display at least one digit to the left and two digits to the right of the decimal separator.
Standard Display number with thousand separator, at least one digit to the left and two digits to the right of the decimal separator.
Percent Display number multiplied by 100 with a percent sign ( % ) appended to the right. Always display two digits to the right of the decimal separator.
Scientific Use standard scientific notation.

The following table identifies characters you can use to create user-defined date/time formats.

Character Description
( : ) Time separator. In some locales, other characters might be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.
( / ) Date separator. In some locales, other characters might be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.
d Display the day as a number without a leading zero (1–31).
dd Display the day as a number with a leading zero (01–31).
ddd Display the day as an abbreviation (Sun–Sat). Localized.
dddd Display the day as a full name (Sunday–Saturday). Localized.
m Display the month as a number without a leading zero (1–12). If m immediately follows h or hh, the minute rather than the month is displayed.
mm Display the month as a number with a leading zero (01–12). If m immediately follows h or hh, the minute rather than the month is displayed.
mmm Display the month as an abbreviation (Jan–Dec). Localized.
mmmm Display the month as a full month name (January–December). Localized.
yy Display the year as a two-digit number (00–99).
yyyy Display the year as a four-digit number (100–9999).
h Display the hour as a number without a leading zero (0–23).
hh Display the hour as a number with a leading zero (00–23).
n Display the minute as a number without a leading zero (0–59).
nn Display the minute as a number with a leading zero (00–59).
s Display the second as a number without a leading zero (0–59).
ss Display the second as a number with a leading zero (00–59).
tt Use the 12-hour clock and display an uppercase AM with any hour before noon; display an uppercase PM with any hour between noon and 11:59 P.M.

The following table identifies characters you can use to create user-defined number formats.

Character Description
None Display the number with no formatting.
( 0 ) Digit placeholder. Display a digit or a zero. If the expression has a digit in the position where the 0 appears in the format string, display it. Otherwise, display a zero in that position. If the number has fewer digits than there are zeros (on either side of the decimal) in the format expression, display leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right, round the number to as many decimal places as there are zeros. If the number has more digits to the left of the decimal separator than there are zeros to the left, display the extra digits without modification.
( # ) Digit placeholder. Display a digit or nothing. If the expression has a digit in the position where the # appears in the format string, display it; otherwise, display nothing in that position. This symbol works like the zero-digit placeholder, except that leading and trailing zeros aren't displayed if the number has the same or fewer digits than there are # characters on either side of the decimal separator in the format expression.
( . ) Decimal placeholder. In some locales, a comma is used as the decimal separator. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only number signs to the left of this symbol, numbers smaller than 1 begin with a decimal separator. To display a leading zero displayed with fractional numbers, use 0 as the first-digit placeholder to the left of the decimal separator. The actual character used as a decimal placeholder in the formatted output depends on the Number Format recognized by your system.
(%) Percentage placeholder. The expression is multiplied by 100. The percent character ( % ) is inserted in the position where it appears in the format string.
( , ) Thousand separators. In some locales, a period is used as a thousand separator. The thousand separator separates thousands from hundreds within a number that has four or more places to the left of the decimal separator. Standard use of the thousand separator is specified if the format contains a thousand separator surrounded by digit placeholders ( 0 or # ). Two adjacent thousand separators or a thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) means "scale the number by dividing it by 1000, rounding as needed." For example, you can use the format string "##0,," to represent 100 million as 100. Numbers smaller than 1 million are displayed as 0. Two adjacent thousand separators in any position other than immediately to the left of the decimal separator are treated simply as specifying the use of a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system.
( : ) Time separator. In some locales, other characters might be used to represent the time separator. The time separator separates hours, minutes, and seconds when time values are formatted. The actual character used as the time separator in formatted output is determined by your system settings.
( / ) Date separator. In some locales, other characters might be used to represent the date separator. The date separator separates the day, month, and year when date values are formatted. The actual character used as the date separator in formatted output is determined by your system settings.
( E- E+ e- e+ ) Scientific format. If the format expression contains at least one digit placeholder ( 0 or # ) to the right of E-, E+, e-, or e+, the number is displayed in scientific format and E or e is inserted between the number and its exponent. The number of digit placeholders to the right determines the number of digits in the exponent. Use E- or e- to place a minus sign next to negative exponents. Use E+ or e+ to place a minus sign next to negative exponents and a plus sign next to positive exponents.
- + $ ( ) Display a literal character. To display a different character, precede it with a backslash (\) or enclose it in double quotation marks (" ").
( \ ) Display the next character in the format string. To display a character that has special meaning as a literal character, precede it with a backslash (\). The backslash itself isn't displayed. Using a backslash is the same as enclosing the next character in double quotation marks. To display a backslash, use two backslashes (\\). Date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, /, and :) can't be displayed as literal characters, the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).
("ABC") Display the string inside the double quotation marks (" ").

For more information, see: