Focal Point
Conditional items in PRINT stmt

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

September 28, 2005, 07:35 PM
Alan Main
Conditional items in PRINT stmt
I would like to conditionally print one item from 2 or more possibilities in a report column.

Normally, I would define an item like so:
ITEM/A8 = IF KeyField EQ 1 THEN 'ONE' ELSE
IF KeyField EQ 2 THEN 'TWO' ......etc
but in this case,
ITEM is a different data type in each case (I know that's not a good scenario but it's what I'm stuck with).
It doesn't work if I define the same name ITEM multiple times with different data types.

If I define
ITEM1/A8 = IF KeyField EQ 1 THEN 'ONE'
ITEM2/D8.1 = IF KeyField EQ 2 THEN 252.8 ....etc

...is there an easy way to tell the PRINT statement which ITEMn to use each time?
If I could assign KeyField to an &variable I could use an -IF statement. Do I have to do a READ on the file for each record (see responses to my earlier post 'Variable column titles')
September 28, 2005, 09:55 PM
j.gross
You want the column to be heterogeneous in a single execution, right?

If all the source fields were numeric (e.g., mixing yen, lira, dollars), you could define a single numeric field in the obvious "IF THEN ELSE ..." manner and use dynamic formatting ("Using Fields to Define Formats" feature).

But as you indicate it's a mix of numeric and alpha field, my only suggestion is to make the printing column a chacater define, using the KeyField to determine what source field to use and how to format it. You can use FTOA() to convert numeric fields into alpha.
September 28, 2005, 10:37 PM
Alan Main
Jack,
what you suggest is exactly what I did for the HTML and PDF versions of the report. But they also want the output in EXCEL, and while it still works, this column (actually there are 15 of them) comes out flagged as numeric data stored as alpha. Kind of ugly. Plus I figured that in a spreadsheet they'd want the numbers to actually be numeric, so I was trying to do that for them. I may be barking up the wrong tree all together - EXCEL probably doesn't even allow this mix of data types in a column?
September 29, 2005, 07:56 AM
Tony A
Maina,

Excel 'allows' the mix of data formats in columns but WebFOCUS doesn't create them in different formats.

The flagging of 'numeric data stored as alpha' is actually an Excel feature to highlight possible problems with the worksheet/book and. I think, can be turned off.

If you are on 5.3 or earlier then you could use an Excel workbook with VBA code to pull the data down and interpret the data contained within each cell and adjust the format as required.

If you are on 7.1 then you could output your WebFOCUS to a template with the same sort of functionality.