Jump to content
The ibi Community has moved to a new platform: Please Sign In and choose Forgot Password to continue

Tips & Tricks: Dynamic column formats


Clayton Peacock

Recommended Posts

Dynamic column formats: 

DEFINE FILE CAR
KPI_LABEL/A100 = 'My ENGLAND label:';
KPI_CALC/D20.2 = RETAIL_COST - DEALER_COST;
KPI_FORMAT/A10 = 'D20.2CM';
END

TABLE FILE CAR
SUM KPI_CALC
BY KPI_LABEL
BY KPI_FORMAT
WHERE COUNTRY EQ 'ENGLAND';
ON TABLE HOLD AS HLD1_ENGLAND
END
-RUN 

DEFINE FILE CAR
KPI_LABEL/A100 = 'My Japan label:';
KPI_CALC/D20.2 = ((RETAIL_COST-DEALER_COST)/100)*-1;
KPI_FORMAT/A10 = 'D20.1%B';
END

TABLE FILE CAR
SUM KPI_CALC
BY KPI_LABEL
BY KPI_FORMAT
WHERE COUNTRY EQ 'JAPAN';
ON TABLE HOLD AS HLD1_JAPAN
END
-RUN

TABLE FILE HLD1_ENGLAND
HEADING
"Tips and Tricks: Dynamic column formats"

-* Dynamic format for column KPI_CALC based on format specified in KPI_FORMAT column
SUM KPI_CALC/KPI_FORMAT

    KPI_FORMAT
BY KPI_LABEL
MORE 
FILE HLD1_JAPAN
END

 

image.png

  • Like 1
Link to comment
Share on other sites

Or if I can suggest another sample from yours Clayton

Quote

DEFINE FILE CAR
KPI_LABEL/A100 = DECODE COUNTRY ('ENGLAND' 'My England label:' 'JAPAN' 'My Japan label:' ELSE 'Other Label:');
KPI_CALC/D20.2 = IF COUNTRY EQ 'ENGLAND' THEN RETAIL_COST - DEALER_COST
            ELSE IF COUNTRY EQ 'JAPAN'   THEN ((RETAIL_COST-DEALER_COST)/100)*-1
            ELSE RETAIL_COST;
KPI_FORMAT/A10 = DECODE COUNTRY ('ENGLAND' 'D20.2CM' 'JAPAN' 'D20.1%B' ELSE 'D20.2');
END
TABLE FILE CAR

SUM KPI_CALC/KPI_FORMAT
    KPI_FORMAT
BY COUNTRY NOPRINT
BY KPI_LABEL

HEADING
"Tips and Tricks: Dynamic column formats"
ON TABLE SET PAGE-NUM NOLEAD
END

 

Link to comment
Share on other sites

It's good to illustrate several technic into one sample 🙂

For those who may not know, good to highlight when using MORE for each used files:

1- Need same number of fields

2- Need same field's name

3- Need same field's format

4- Need same field's order

Edited by Martin Yergeau
  • Like 2
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...