Jump to content

App Studio Report - Format negative number red?


robert fuschetto

Recommended Posts

There is the MACRO and STYLE way such as below

I think that a new style attribute as been added to perform this but can't remember which one (if exist)

DEFINE FILE GGSALES
N_SLS /P8CB = IF EDIT(CITY, '9') IN ('B','H','M') THEN DOLLARS * -1 ELSE DOLLARS;
END
TABLE FILE GGSALES
SUM N_SLS AS 'Sales $'
BY CITY   AS 'City'
ON TABLE SET STYLE *
     DEFMACRO=NEG_SLS,
     MACTYPE=RULE,
     WHEN=N_SLS LT 0,
$
TYPE=DATA,
     COLUMN=N_SLS,
     COLOR=RED,
     MACRO=NEG_SLS,
$
ENDSTYLE
END

 

Edited by Martin Yergeau
  • Like 1
Link to comment
Share on other sites

I prefer to code it more simply, without the MACRO:

DEFINE FILE GGSALES
N_SLS /P8CB = IF EDIT(CITY, '9') IN ('B','H','M') THEN DOLLARS * -1 ELSE DOLLARS;
END
TABLE FILE GGSALES
SUM N_SLS  AS 'Sales $'
 BY CITY   AS 'City'
ON TABLE SET STYLE *
TYPE=DATA,
     COLUMN=N_SLS,
     COLOR=RED,
     WHEN=N_SLS LE 0,
$
ENDSTYLE
END

 

  • Like 1
Link to comment
Share on other sites

Does work without the MACRO since condition is simple : N_SLS LT 0

But for more complex condition you may need to use the MACRO technic sunch as below

DEFINE FILE GGSALES
N_SLS /P8CB = IF EDIT(CITY, '9') IN ('B','H','M') THEN DOLLARS * -1 ELSE DOLLARS;
END
TABLE FILE GGSALES
SUM N_SLS AS 'Sales $'
    COMPUTE T_SLS /A1 = IF N_SLS LT 0 OR N_SLS GT 4000000 THEN 'Y' ELSE 'N'; NOPRINT
BY CITY   AS 'City'
ON TABLE SET STYLE *
     DEFMACRO=HIGHLIGHT_SLS,
     MACTYPE=RULE,
     WHEN=T_SLS EQ 'Y',
$
TYPE=DATA,
     COLUMN=N_SLS,
     COLOR=RED,
     MACRO=HIGHLIGHT_SLS,
$
ENDSTYLE
END

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
  • Create New...