Focal Point
[SOLVED] How to Repeat a Value for each row

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

April 22, 2020, 09:47 PM
FOCdeveloper
[SOLVED] How to Repeat a Value for each row
Hello All
I need to repeat a value for every row
For example I have column called flda, it has a value , I need to repeat this value for all other rows in fldb
example
flda fldb
row1 0001 45
row2 0002 0
row3 0003 0
row4 0004 0
...
row99 0099 0

in the above example I will need fldb with the value of 45 for all rows

Thanks

This message has been edited. Last edited by: FP Mod Chuck,


Prod/Dev/Test: WF 8.1.5 on (Windows Server 2012 R2 )
SandBox: WebFocus Server 8.1.5 on Windows Server 2008 R2
WebFOCUS App Studio 8.1.5 and Developer Studio 8.1.5 on Windows 7
April 23, 2020, 06:08 AM
Frans
YOu can use PARTITION_AGGR fo rthis:

 
DEFINE FILE CAR
SRT/I1=0;
END
TABLE FILE CAR
PRINT SALES 
COMPUTE FST/D12.2M = PARTITION_AGGR(SALES, SRT, B, C, FST);
BY SRT
BY COUNTRY
WHERE COUNTRY EQ 'W GERMANY'
ON TABLE SET PAGE NOLEAD
END
 



Test: WF 8.2
Prod: WF 8.2
DB: Progress, REST, IBM UniVerse/UniData, SQLServer, MySQL, PostgreSQL, Oracle, Greenplum, Athena.
April 23, 2020, 09:03 AM
FOCdeveloper
quote:
PARTITION_AGGR


Thank You I tried that , for some reason it does not like

 
 DEFINE FILE CAR
 SRT/I1=0;
 END
 TABLE FILE CAR
 PRINT SALES
 COMPUTE FST/D12.2M = PARTITION_AGGR(SALES, SRT, -1, C, FST);
 BY SRT
 BY COUNTRY
 WHERE COUNTRY EQ 'W GERMANY'
 ON TABLE SET PAGE NOLEAD
 END
 0 ERROR AT OR NEAR LINE      9  IN PROCEDURE ADHOCRQ FOCEXEC *
 (FOC258) FIELDNAME OR COMPUTATIONAL ELEMENT NOT RECOGNIZED: C
 (FOC009) INCOMPLETE REQUEST STATEMENT
 BYPASSING TO END OF COMMAND


 



Prod/Dev/Test: WF 8.1.5 on (Windows Server 2012 R2 )
SandBox: WebFocus Server 8.1.5 on Windows Server 2008 R2
WebFOCUS App Studio 8.1.5 and Developer Studio 8.1.5 on Windows 7
April 23, 2020, 09:36 AM
FOCdeveloper
i THINK THIS FEATURE IS NOT AVAILABLE IN 8.1.5m WHICH WE HAVE


Prod/Dev/Test: WF 8.1.5 on (Windows Server 2012 R2 )
SandBox: WebFocus Server 8.1.5 on Windows Server 2008 R2
WebFOCUS App Studio 8.1.5 and Developer Studio 8.1.5 on Windows 7
April 23, 2020, 11:27 AM
Hallway
If you don't have a need to partition by a BY field then you can set up a simple counter using LAST (you can then hide the counter with a NOPRINT). Then using IF...THEN logic you can bring down the values of the first line.

  
TABLE FILE GGSALES
PRINT  
   COMPUTE COUNTER/I4 = LAST COUNTER + 1; NOPRINT
   COMPUTE flda/A4 = EDIT(COUNTER);
   COMPUTE fldb/I11 = IF COUNTER EQ 1 THEN DOLLARS ELSE LAST fldb;
BY PCD NOPRINT
ON TABLE SET PAGE-NUM OFF
ON TABLE SET BYDISPLAY ON
ON TABLE SET STYLE *
TYPE=REPORT, LINES-PER-PAGE=UNLIMITED, $
END


If you want to break it up between BY fields you can do that as well using LAST
  
TABLE FILE GGSALES
PRINT  
   COMPUTE PARTITION_NUM/I4 = IF PCD NE LAST PCD THEN PARTITION_NUM + 1 ELSE PARTITION_NUM; 
   COMPUTE PARTITION_ROW/I4 = IF PCD NE LAST PCD THEN 1 ELSE LAST PARTITION_ROW + 1;
   COMPUTE FIRST_DOLLARS/I11 = IF PARTITION_ROW EQ 1 THEN DOLLARS ELSE LAST FIRST_DOLLARS;
   COMPUTE RUNNING_TOTAL/I11 = IF PARTITION_ROW EQ 1 THEN DOLLARS ELSE LAST RUNNING_TOTAL + DOLLARS ;
BY PCD
ON TABLE SET PAGE-NUM OFF
ON TABLE SET BYDISPLAY ON
ON TABLE SET STYLE *
TYPE=REPORT, LINES-PER-PAGE=UNLIMITED, $
END

This message has been edited. Last edited by: Hallway,


Hallway

 
Prod: 8202M1
Test: 8202M4
Repository:
 
OS:
 
Outputs: