Formatting Data

Formatting Data

Logi Info
v12.6 SP3 - Mar 2019

Many elements have a Format attribute that lets you specify how its data will be formatted. The most common of these, for example, is the Label element. Applying formatting to a Label caption is especially useful for dates, times, and certain types of numbers. This document described the available options; topics include:

 

About Formatting

The following elements have a Format attribute, which can be set to format the appearance of their data:

  • Analysis Chart Column
  • Analysis Filter Column
  • Analysis Grid Column
  • Animated Map Color Spectrum Legend
  • Caption Style
  • Chart Grid Column
  • Color Spectrum Legend
  • Crosstab Comparison
  • Crosstab Table Value Columns
  • Data Labels
  • Data Scale
  • Drill To Column
  • Drillthrough Column
  • Formatted Column
  • Gauge Label

 

  • Heatmap Group
  • Heatmap Label
  • Heatmap Label Style
  • Input Combo List
  • Input Date
  • Input Number
  • Input Telephone
  • Input Text
  • Input Text Area
  • Input Time
  • Label
  • Label Scale
  • Label Style
  • Legend
  • Marker Label Style
  • MDX Calculated Measure
  • PDF Form Field
  • Polygon Color Spectrum Legend
  • Quicktip Row
  • Schedule
  • Side Label Style
  • Stack Labels
  • SubCaption Style
  • Word Form Field
  • XOLAP Calculated Measure
  • XOLAP Level
  • XOLAP Measure
  • XOLAP Member Property

Logi Studio is not always context-sensitive when it comes to the options available for Format attributes, so it may be possible to select formatting options that are not appropriate for the data.

Many of the formatting types available are dependent on the Regional settings in the web server's operating system.

 


For example, as shown above, Regional and Language options are available on Windows-based web servers through the Control Panel. The "Currency", "Short date" and "Long date" formats defined here can be used by name in a Format attribute.

  Back to the top

 

Standard Formats

The following standard formats are available, from a pull-down list, in Studio for elements' Format attribute value:
 

Type

Description

<

Converts all characters to lower-case.

>

Converts all characters to upper-case.

Expanded Spaces

Preserves space characters that are normally collapsed by the web browser. This formatting will not be applied if used with content that includes more than one @Data token.

Preserve Line Feeds

Preserves line breaks (CTRL-ENTER). This formatting will not be applied if used with content that includes more than one @Data token.

HTML

Preserves HTML tags, embedding them rather than encoding them. Text appearance and alignment is affected by the tags; they are not seen in the text.

General Date

Display a date and/or time. For real numbers, display a date and time, for example, 4/3/93 05:34 PM. If there is no fractional part, display only a date, for example, 4/3/93. If there is no integer part, display time only, for example, 05:34 PM. Date display is determined by the web server's settings.

Long Date

Display a date according to the web server's Long Date format.

Medium Date

Display a date using the Medium Date format appropriate for the language version of the host application on the web server.

Short Date

Display a date using web servers's Short Date format.

Long Time

Display time using the web server's Long Time format; includes hours, minutes, seconds.

Medium Time

Display time in 12-hour format using hours and minutes and the AM/PM designator.

Short Time

Display time using the 24-hour format, for example, 17:45.

yyyy/MM/dd

A custom date/time format defined by the developer using the components described in the next section.

hh:mm

Display time as hours and minutes, with leading zeroes. Example: 01:08

yyyy/MM/dd hh:mm:ss

Display date and time, with leading zeroes. Example: 2007/01/01 01:08:02

General Number

Display number with no thousands separator.

Currency

Display number with currency symbol, thousands separators (if appropriate), and two digits to the right of the decimal separator. The symbols and characters used are based on the end-user's browser culture settings or computer system settings. For example, United States = "en-us" = $1,000.00, United Kingdom = "en-gb" = 1.000,00.

Fixed

Display at least one digit to the left and two digits to the right of the decimal separator.

Standard

Display number with thousands 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.

mp

Formats numbers by applying the appropriate "metric prefixes" (giga-, mega-, kilo-, etc.) . Example: "1,234,567" formatted with "$#.00mp" produces "$1.23M". More information about metric prefixes can be found here. Customization of the mp format can be accomplished using the Globalization element's Metric Prefix String attribute.

mps3

Identical to the mp format, but allows rounding to three significant digits. Example: A value of 123456, with format mps3, returns 123K.

###,###,##0.00

Display number with thousands separator for every three digits to left, at least one digit to the left and two digits to the right of the decimal separator.

Yes/No

Display No if number is 0; otherwise, display Yes.

True/False

Display False if number is 0; otherwise, display True.

On/Off

Display Off if number is 0; otherwise, display On.

 

The HTML format, when used with a Label caption, allows you to embed HTML code in the report. This be used to accomplish things as simple as making part of a line bold-faced using <B> tags, or as complicated as including scripts within <SCRIPT> tags for various purposes. When using the HTML format, ensure that you do not include a <BODY> tag that might confuse the Logi Server Engine when it generates its HTML output.

Hint: Use these standard date/time and numeric formats to improve performance with large reports.

Note that the standard numeric formats, such as Currency, may cause rounding, and this may affect aggregations and summaries of the data.

  Back to the top

 

Custom Date and Time Formats

In addition to the standard formats listed above, developers can enter custom date and time formats by typing them in directly.

For example, one of the standard date formats is "yyyy/MM/dd". Developers can directly enter other combinations of valid formatting characters, such as "MM/dd/yyyy" to obtain the desired format. Note that format values are case-sensitive and are not entered with quotation marks. Here are the valid date and time formatting characters:
 

Chars

Description

:

Time separator. In some locales, other characters may 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 the client OS locale setting.

/

Date separator. In some locales, other characters may 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 the client OS locale setting.

%

Used to indicate that the following character should be read as a single-letter format without regard to any trailing letters. Also used to indicate that a single-letter format is read as a user-defined format. See below for further details.

d

Day as a number, without a leading zero: 1. Use %d if this is the only character in your user-defined numeric format.

dd

Day of month number, with leading zero: 04

ddd

Three-letter abbreviation of day name: Wed

dddd

Full day name: Thursday

Week\: ww

Week number since beginning of year: Week: 51. This format is affected by the Globalization element's First Day Of Week attribute.

M

Full month name and day combination: July 22

MM

Month number: 07

MMM

Three-letter month name abbreviation: Jul

MMMM

Full month name: September

gg

The period/era: A.D. Note that this is not available in Format Label and Format Data elements.

qq

Quarter number: 1, 2, 3, or 4. Note that this is not available in Format Label and Format Data elements.

fqq

Fiscal year quarter. Example: \FY fyyyy-Qfqq outputs FY 2019-Q2. This format is affected by the Globalization element's First Day Of Fiscal Year attribute.

y

Year number (0-9), without leading zeros. Use %y if this is the only character in your user-defined numeric format.

yy

Two-digit year, with a leading zero, but without century: 09

yyyy

Four-digit year: 2009

fyy

Two-digit fiscal year. Example: \FYfyy outputs FY18. This format is affected by the Globalization element's First Day Of Fiscal Year attribute.

fyyyy

Four-digit fiscal year. Example: \FYfyy outputs FY2018. This format is affected by the Globalization element's First Day Of Fiscal Year attribute.

h

Hour as a number, without a leading zero, using the 12-hour clock: 1:15:15 PM. Use %h if this is the only character in your user-defined numeric format.

hh

Hour as a number, with a leading zero, using the 12-hour clock: 04

H

Hour as a number, without a leading zero, using the 24-hour clock: 13:15:15 PM. Use %H if this is the only character in your user-defined numeric format.

HH

Hour as a number, with a leading zero, using the 24-hour clock: 01

m

Minute as a number, without leading zeros: 12:1:15. Use %m if this is the only character in your user-defined numeric format.

mm

Minute as a number, with leading zeros: 12:01:15

s

Second as a number, without leading zeros: 12:1:5. Use %m if this is the only character in your user-defined numeric format.

ss

Second as a number, with a leading zero: 12:1:05

f

Fractions of a second. For example, ff will display hundredths of seconds, whereas ffff will display ten-thousandths of seconds. You may use up to seven f symbols in your user-defined format. Use %f if this is the only character in your user-defined numeric format.

T

Uses the 12-hour clock and displays an uppercase A for any hour before noon; displays an uppercase P for any hour between noon and 11:59 P.M.

t

Hour and minute with AM/PM designator: 10:32 AM

tt

AM or PM designator alone: PM

z

Timezone offset as a number, without a leading zero: -8. Use %z if this is the only character in your user-defined numeric format.

zz

Timezone offset as a number, with a leading zero: -08

zzz

Full timezone offset as a number, with a leading zero: -08:00

 

Visit the Microsoft Custom Date/Time Formats page for more information.

   Back to the top

 

Custom Numeric Formats

In addition to the standard formats listed above, developers can enter custom numeric formats by typing them in directly.

For example, one of the standard date formats is "###,###,##0.00". Developers can directly enter other combinations of valid formatting characters, such as "$#,##0" to obtain the desired format. Here are the valid numeric formatting characters:
 

Chars

Description

None

Displays the number with no formatting.

0

Digit placeholder. Displays a digit or a zero. If the expression has a digit in the position where the zero appears in the format string, display it; otherwise, displays 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, displays leading or trailing zeros. If the number has more digits to the right of the decimal separator than there are zeros to the right of the decimal separator in the format expression, rounds 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 of the decimal separator in the format expression, displays the extra digits without modification.

#

Digit placeholder. Displays a digit or nothing. If the expression has a digit in the position where the # character appears in the format string, displays it; otherwise, displays nothing in that position.

This symbol works like the 0 digit placeholder, except that leading and trailing zeros aren't displayed if the number has fewer digits than there are # characters on either side of the decimal separator in the format expression.

.

Decimal placeholder. The decimal placeholder determines how many digits are displayed to the left and right of the decimal separator. If the format expression contains only # characters 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 zero as the first digit placeholder to the left of the decimal separator. In some locales, a comma is used as the decimal separator. The actual character used as a decimal placeholder in the formatted output depends on the number format recognized by your system. Thus, you should use the period as the decimal placeholder in your formats even if you are in a locale that uses a comma as a decimal placeholder. The formatted string will appear in the format correct for the locale.

%

Percent placeholder. Multiplies the expression by 100. The percent character (%) is inserted in the position where it appears in the format string.

,

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 #). A thousand separator immediately to the left of the decimal separator (whether or not a decimal is specified) or as the rightmost character in the string means "scale the number by dividing it by 1,000, rounding as needed."

For example, you can use the format string "##0,." to represent 100 million as 100,000. Numbers smaller than 1,000 but greater or equal to 500 are displayed as 1, and numbers smaller than 500 are displayed as 0. Two adjacent thousand separators in this position scale by a factor of 1 million, and an additional factor of 1,000 for each additional separator.

Multiple separators in any position other than immediately to the left of the decimal separator or the rightmost position in the string are treated simply as specifying the use of a thousand separator. In some locales, a period is used as a thousand separator. The actual character used as the thousand separator in the formatted output depends on the Number Format recognized by your system. Thus, you should use the comma as the thousand separator in your formats even if you are in a locale that uses a period as a thousand separator. The formatted string will appear in the format correct for the locale.

E- E+ e- e+

Scientific format. If the format expression contains at least one digit placeholder (0 or #) to the left 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 left 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. You must also include digit placeholders to the right of this symbol to get correct formatting.

- + $ ( )

Literal characters. These characters are displayed exactly as typed in the format string. To display a character other than one of those listed, precede it with a backslash (\) or enclose it in double quotation marks (" ").

\

Displays 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 (\\).

Examples of characters that can't be displayed as literal characters are the date-formatting and time-formatting characters (a, c, d, h, m, n, p, q, s, t, w, y, /, and :), the numeric-formatting characters (#, 0, %, E, e, comma, and period), and the string-formatting characters (@, &, <, >, and !).

 

Visit the Microsoft Custom Numeric Formats page for more information.


Positive and Negative Number Formatting

To construct a custom format for currency or numbers that treats positive and negative numbers differently, use a semi-colon and a space in the Format attribute to delineate two formats:
 

For example, the Format value shown above will show positive numbers with a comma as a thousands separator. It will show negative numbers in the same way but also enclose them in parenthesis. Note the semi-colon and space which separate the positive and negative formats.

You can also use the Conditional Class element, beneath any Label element that displays numeric data, to display negative numbers in a different color than positive numbers.

  Back to the top

 

The Formatted Column Element

A special element, the Formatted Column element, allows developer to format data right in a datalayer. The element formats data from another column and places it in a new column in the datalayer. All of the formatting options previously discussed here are available in this element and using the Formatted Column can produce report performance improvements.

For more information, see our document The Formatted Column.

  Back to the top

 


© Copyright 2007-2019 Logi Analytics, Inc. All Rights Reserved