Focal Point
[CLOSED] Change the font to green when there is negative value

This topic can be found at:
http://forums.informationbuilders.com/eve/forums/a/tpc/f/7971057331/m/6807037576

April 23, 2015, 07:09 AM
info4pal
[CLOSED] Change the font to green when there is negative value
Hi,

I have a query and say if I run it,say I may get columns 1,2 and 3 and out of which column 3 gives the number of units sold in $.
Now say I will get 3 rows for Column 3 with the values such as $3.00(row 1), $-4.99(row2 ) and $-5.00 (row 3).I need to change the font to green only if there is negative currency(say in the above case,it is row 2 and row3) and to black font if it is a positive currency(row 1).

Can anyone please let me know how to do this in a styling part/section using sample car file.

Any help is greatly appreciated.

Thanks a lot in advance!

Regards,
IP

This message has been edited. Last edited by: <Kathryn Henning>,


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
April 23, 2015, 08:32 AM
MartinY
GUI does it for you.

Right click on field you want to apply color, Options, Style, Edit Conditions, New, Apply color to font.

TABLE FILE CAR
PRINT
     COMPUTE N_RET/D10 = RETAIL_COST - 10000;
BY  CAR.ORIGIN.COUNTRY
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE SET STYLE *
$
     DEFMACRO=COND0001,
     MACTYPE=RULE,
     WHEN=N2 LT 0,
$
TYPE=DATA,
     COLUMN=N2,
     COLOR='GREEN',
     MACRO=COND0001,
$
ENDSTYLE
END



WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
April 23, 2015, 06:33 PM
Waz
It is also in the documentation.

Take a look at MACRO's and the WHEN statement.


Waz...

Prod:WebFOCUS 7.6.10/8.1.04Upgrade:WebFOCUS 8.2.07OS:LinuxOutputs:HTML, PDF, Excel, PPT
In Focus since 1984
Pity the lost knowledge of an old programmer!

April 24, 2015, 03:58 AM
SWES
I mostly skip the MACRO part for clarity and prefer to use the column names. This way when columns are being added or removed, the conditional styling keeps working and there is no need for renumbering:

 TABLE FILE CAR
PRINT
     COMPUTE N_RET/D10 = RETAIL_COST - 10000;
BY  CAR.ORIGIN.COUNTRY
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE SET STYLE *
$
TYPE=DATA,
     COLUMN=N_RET,
     COLOR='GREEN',
     WHEN=N_RET LT 0,
$
ENDSTYLE
END
 



WebFOCUS 8105m
Windows 7, All Outputs

Member of the Benelux Usergroup
April 24, 2015, 08:05 AM
MartinY
You are right SWES, using the MACRO with the column name is normally what I am doing, but I did the code with the GUI just to be sure that everything remain as the GUI does and show that it's possible.

The advantage of the MACRO is that it can be reused for many columns' styling without having to define the condition on every columns.

It also make the code more clear when using the field name instead of the reference. Using the reference may sometime be confusing especially with COMPUTEs and MULTI LEVEL. Many treads speak about a column with style change when it's not supposed to be that one because a internal MATRIX field (not displayed) as to be considered in the column reference count.


WF versions : Prod 8.2.04M gen 33, Dev 8.2.04M gen 33, OS : Windows, DB : MSSQL, Outputs : HTML, Excel, PDF
In Focus since 2007
April 24, 2015, 08:24 AM
SWES
Martin, true that!


WebFOCUS 8105m
Windows 7, All Outputs

Member of the Benelux Usergroup
April 28, 2015, 12:23 PM
info4pal
Hi,

Thanks a lot for the quick response.
But I have to enclose that value within braces say {$3.00}....

Any help is greatly appreciated.

Thanks a lot in advance!

Regards,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
April 28, 2015, 12:27 PM
Tom Flynn
This is very simple; I "always" set a FLAG and never use DEFMACRO, my 2 cents:
  
TABLE FILE CAR
PRINT
     COMPUTE N_RET/P10.2BC = RETAIL_COST - 10000;
     COMPUTE FLAG/A1 = IF N_RET LT 0 THEN 'Y' ELSE 'N'; NOPRINT
BY  CAR.ORIGIN.COUNTRY
ON TABLE SET PAGE-NUM NOLEAD
ON TABLE NOTOTAL
ON TABLE SET STYLE *
$
TYPE=DATA,
     COLUMN=N_RET,
     COLOR='GREEN',
     WHEN=FLAG EQ 'Y',
$
ENDSTYLE
END
-EXIT



Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe
April 28, 2015, 12:34 PM
info4pal
Hi,

I need this bracket -> ($3.00)...Sorry for the confusion.

Thanks,
IP


Webfocus 8105 Developer studio,Windows 7,HTML,Excel,PDF,Text,Infoassist,Graph,AHTML
April 28, 2015, 12:42 PM
Tom Flynn
P10.2BCM


Tom Flynn
WebFOCUS 8.1.05 - PROD/QA
DB2 - AS400 - Mainframe