Focal Point
summarize/recompute giving weird result.
May 31, 2007, 04:42 AM
Alan Bsummarize/recompute giving weird result.
Hope I am not totally gone this morning.
From this simple code:
TABLE FILE CAR
SUM SALES NOPRINT
SUM SALES
COMPUTE PERCENT/D6.1 = (C2/C1)*100;
BY COUNTRY RECOMPUTE (OR SUMMARIZE)
IF COUNTRY EQ JAPAN OR 'W GERMANY'
END
I would expect:
COUNTRY SALES PERCENT
JAPAN 78030 46.9
*TOTAL JAPAN
78030 46.9
W GERMANY 88190 53.1
*TOTAL W GERMANY
88190 53.1
TOTAL
166220 100.0
What I get is:
COUNTRY SALES PERCENT
JAPAN 78030 46.9
*TOTAL JAPAN
78030 .0
W GERMANY 88190 53.1
*TOTAL W GERMANY
88190 53.1
TOTAL
166220 100.0
To overcome this I have to use:
TABLE FILE CAR
SUM SALES NOPRINT
SUM SALES
COMPUTE YSALES/I6=IF C1 EQ 0 THEN LAST YSALES ELSE C1; NOPRINT
COMPUTE PERCENT/D6.1 = (C2/YSALES)*100;
BY COUNTRY RECOMPUTE
IF COUNTRY EQ JAPAN OR 'W GERMANY'
END
Anyone any explanation please.
(Also tried on 7.6 and 4.3 with same result so do think I am out of it)
Alan.
WF 7.705/8.007
May 31, 2007, 05:14 AM
Tony AAlan,
Seems to be a problem with using column notation. If you use -
TABLE FILE CAR
SUM SALES NOPRINT
SUM SALES
COMPUTE PERCENT/D6.1 = (C2/TOT.SALES)*100;
BY COUNTRY RECOMPUTE
IF COUNTRY EQ 'JAPAN' OR 'W GERMANY'
END
the result is as you would expect without the IF ... THEN ... ELSE ...;
T
Except that the total percentage isn't correct
In FOCUS since 1986 | WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2 | | |
WebFOCUS App Studio 8.2.06 standalone on Windows 10 | |
May 31, 2007, 05:39 AM
Alan BTony,
I wasn't so sure it was really the column notation, and TOT. only overcomes a bit of the problem as you said.
If you take the NOPRINT off SUM SALES and look at its value, it becomes zero after teh first record, then reverts back to it's original value on the last record.
Alan.
WF 7.705/8.007
May 31, 2007, 09:11 AM
LeahThis code gives the results you wanted, but not knowing the complete application, you may not be able to use subtotal
TABLE FILE CAR
SUM SALES NOPRINT
SUM SALES
COMPUTE PERCENT/D6.1 = (C2/C1)*100;
BY COUNTRY
IF COUNTRY EQ JAPAN OR 'W GERMANY'
ON COUNTRY SUBTOTAL
END
Leah
May 31, 2007, 09:38 AM
mgrackinAlan,
Try using the PCT. prefix operator. I assume you are creating a COMPUTE field so that you get more precision in the percent value.
Try the following:
DEFINE FILE CAR
NEWSALES/D6.1=SALES;
END
TABLE FILE CAR
SUM SALES PCT.NEWSALES AS '% Sales'
BY COUNTRY RECOMPUTE
IF COUNTRY EQ JAPAN OR 'W GERMANY'
END
Thanks!
Mickey
| FOCUS/WebFOCUS 1990 - 2011 |
May 31, 2007, 09:51 AM
Alan BThanks guys, but the issues are more complex, I was just showing the problem in a simple way.
Calculation is needed using both parts of the multi verb request and a recompute.
It is really a question as to whether I should expect this to work, is it a feature, or worse.
Alan.
WF 7.705/8.007
May 31, 2007, 09:51 AM
mgrackinAlan,
I would also open a tech support case with IBI with the code you posted. This looks like a bug. If not, at least Art or Noreen may be able to explain why you got a 0 on the first RECOMPUTE and not the other.
Thanks!
Mickey
| FOCUS/WebFOCUS 1990 - 2011 |
May 31, 2007, 10:08 AM
Tony AI would agree that it is a likely "feature" is as much that the SUBTOTAL (as per Leah) functions exactly as you would expect but the RECOMPUTE and SUMMARIZE do not.
Let us know what comes of it should you decide to progress.
It is also worth noting the results when you remove the selection clause. The only correct RECOMPUTE value is the last one - no wonder you began questioning ....
T
In FOCUS since 1986 | WebFOCUS Server 8.2.01M, thru 8.2.07 on Windows Svr 2008 R2 | | |
WebFOCUS App Studio 8.2.06 standalone on Windows 10 | |
May 31, 2007, 11:47 AM
Alan BThanks Mickey and Tony,
I like to check I am sane before opening a case, but will do so and give results back here.
Alan.
WF 7.705/8.007
May 31, 2007, 12:11 PM
KerryHi Alan and all,
Please try the following suggestion from internal FOCUS wizards:
DEFINE FILE CAR
CTR/I5 WITH COUNTRY= 1;
END
TABLE FILE CAR
SUM
TOT.SALES NOPRINT
CTR NOPRINT
SALES
COMPUTE PERCENT/D6.1 = (C3/(C1/C2))*100;
BY COUNTRY
ON COUNTRY RECOMPUTE
IF COUNTRY EQ JAPAN OR 'W GERMANY'
END
The issue is, using TOT.SALES (or SALES WITHIN TABLE), you get the TOTAL for each COUNTRY. On the grand 'RECOMPUTE', you have 'n' times the value, where 'n' is the number of COUNTRYs. By dividing by the DEFINEd field CTR, it's dividing by 1 for each country, and by 'n' on the grand RECOMPUTE (that's why it needed to be a DEFINE, not a COMPUTE).
If you use the multi-verb approach, as originally given, the grand total of SALES isn't available until the end; you can't use it at an 'ON COUNTRY' action, as it's not available at that level, only on the TABLE level (which is why the last calculation is correct).
Hope this helps.
Cheers,
Kerry
Kerry Zhan
Focal Point Moderator
Information Builders, Inc.
June 01, 2007, 01:42 PM
Alan BOooh! Heavy.
From IB:
Using the 'global' value at a sort field break, gives a ZERO result, as the value is not available at that level, but only at the GLOBAL level, which is why only the LAST calculation is correct.
Here's how to do it:
DEFINE FILE CAR
CTR/I5 WITH COUNTRY= 1;
END
TABLE FILE CAR
SUM
TOT.SALES NOPRINT
CTR NOPRINT
SALES
COMPUTE PERCENT/D6.1 = (C3/(C1/C2))*100;
BY COUNTRY
ON COUNTRY RECOMPUTE
IF COUNTRY EQ JAPAN OR 'W GERMANY'
END
It gets the TOTAL at the detail level, and uses the CTR field to avoid having multiple instances.
(Message End. Thank you Raoul.)
Which makes sense, I suppose. Anyway it does work, just make sure you have CNTR else the RECOMPUTE subtotal will be wrong.
Alan.
WF 7.705/8.007