February 05, 2008, 01:59 PM
AnatessPulling 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.
February 05, 2008, 02:09 PM
LeahDo 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.
February 05, 2008, 02:12 PM
jimster06In 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.
February 05, 2008, 03:35 PM
AnatessI 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?
February 05, 2008, 03:47 PM
LeahGenerically
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.
February 05, 2008, 11:35 PM
AnatessOkay, 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.
February 06, 2008, 02:14 AM
Alan BAnatess
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