Focal Point
Pulling data from 2 different tables to use in computation

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

February 05, 2008, 01:59 PM
Anatess
Pulling data from 2 different tables to use in computation
Hi all -

I'm not quite sure how to accomplish this.
I have a table of values by month. Simplified as:
PROJECT, RESOURCE, HOURS, MONTH
I also have another table of values, one entry per month as follows:
MONTH, FTEHRS
I need to write a report as follows:
(SUM HOURS/SUM FTEHRS) ACROSS RESOURCE BY PROJECT WHERE MONTH FALLS BETWEEN SOME FILTER CRITERIA.


WF 8.1.05 Windows
February 05, 2008, 02:09 PM
Leah
Do the tables have a key in common? You basically have the report process in pseudo code, but you need to have the tables joined some way or extract the data from each to two hold files and 'create a common key on both' then join the hold files.


Leah
February 05, 2008, 02:12 PM
jimster06
In the upper right portion of this screen, there is a reference to Search the Technical Documentation Library. You can look there for information regarding the JOIN and Match commands.


jimster06
DevStu WF 7.6.11
W7
HTML, PDF, EXL2K
February 05, 2008, 03:35 PM
Anatess
I can handle join just fine. But the thing is, the two tables are not supposed to join. I need to get the sum of all hours from table1 within the date range provided by the user (as & parms) for each project and resource within project. Then, sum all of the ftehrs from table2 within the date range. Then perform the computation between the two. So, here's sample data:
Table 1:
Month, Project, Resource, Hours
January, Project A, Leah, 80
January, Project A, Leah, 80
January, Project A, Jimster, 150 
January, Project B, Linda, 160
February, Project A, Anatess, 160
February, Project A, Leah, 118
February, Project B, Linda, 118


Now, Table 2:
Month, FTE
January, 160
February, 118
March, 160


Now, the report for date range January and February would be:
                Anatess   Jimster  Leah  Linda
Project A        0.57      0.53     1      
Project B                                  1


This is how the numbers are computed:
(Sum of hours from table1)/(Sum of ftehrs from table2)
Project A, Anatess = 0.57 = 160/(160+118)
Leah = 1 = (80+80+118)/(160+118)

So, do you see how it's not really a join? Does that make sense?


WF 8.1.05 Windows
February 05, 2008, 03:47 PM
Leah
Generically

sum the project hours by month by project by person and hold the data, then in the month table pull the month and sort the FTE by month and hold in another file then join the tables by month and perform your calculations. I think second file to first will do as long as you do a join to all. If that overstates the ftehrs, try reversing the join.


Leah
February 05, 2008, 11:35 PM
Anatess
Okay, I figured it out.
What I did is this:
TABLE FILE TABLE2
SUM FTEHRS
WHERE PRDMTH GE '&STARTDTE' AND START_DATE LE '&ENDDTE';
ON TABLE SAVE
END
-RUN
-READ SAVE &FTE.I11
TABLE FILE TABLE1
SUM HOURS NOPRINT
    COMPUTE FTEEQ/D12.2 = SUM.HOURS / &FTE;
BY PROJECT
ACROSS RESOURCE
WHERE PRDMTH GE '&STARTDTE' AND START_DATE LE '&ENDDTE';
...ETC.


That works perfectly.


WF 8.1.05 Windows
February 06, 2008, 02:14 AM
Alan B
Anatess

This can be done in a JOIN, very easily, by using the hours data first and JOINing to ALL:
JOIN MONTH IN months TO ALL MONTH IN project
TABLE FILE months
SUM months.HOURS NOPRINT
SUM 
COMPUTE RATIO/F8.2 = project.HOURS/C1;
ACROSS RESOURCE
BY PROJECT
WHERE PRDMTH GE '&STARTDTE' AND START_DATE LE '&ENDDTE';
END



Alan.
WF 7.705/8.007