ID: Q104254
The information in this article applies to:
You can create a field in the Expression Builder of a screen or a report to conditionally alter the formatting of a numeric field or variable. See below for more information.
To conditionally alter the formatting of a field, you need to combine the IIF() function with the TRANSFORM() function. For example, suppose you have a table with the following field and records:
YTDPURCH
10000
100
500
125000
500000
1200
1200000
50
9000
In your report, you want to display the values less than 1000 as plain
numbers, the values between 1000 and 100000 as currency with commas,
and the values greater than 1000000 as decimal fractions of a million
with an "M".
To do this, enter the following expression in the Expression Builder of a single field in the Detail band:
IIF(ytdpurch<1000,ytdpurch,IIF(ytdpurch<100000,TRANSFORM(ytdpurch,
'$$$,$$$.99'),TRANSFORM(ytdpurch/1000000,'99.9')+'M'))
The results will appear as follows:
Ytdpurch
$10,000.00
100.00
500.00
0.1M
0.5M
$1,200.00
1.2M
50.00
$9,000.00
Additional reference words: FoxDos FoxWin 2.00 2.50 2.50a writer
multiformatted
multiple formats 2.50b 2.60
KBCategory: kbprg
KBSubcategory: FxtoolGeneral
Last Reviewed: June 27, 1995