Hello,
I have a report where each record represents a different job. I'm trying to write a BQL query to calculate the total number of labor hours left at each workcenter based on how much of the job has been completed. Basically, taking Job Qty Released minus Job Route Qty Completed and then multiplying that result times Job Route Sched Run Labor Hours for each job suffix. Then adding up all the job suffix results for each job.
I created a second report to help me put together the query to pass to my Stat function (See image below). The sum circled in the image is the result I'm trying to get in my first report for each record.

This is my BQL formula for the test column:
(LOOKUPVALUE(0,[Jobs.Job],1,[Jobs.Job Suffix],SELECT [Jobs.Job],[CO Line Due Date: Min: Job Qty Released] from [All] WHERE [Jobs.Job Suffix]=%0)-[CO Order Date: Sum: Job Route Qty Completed])*[CO Create Date: Sum: Job Route Sched Run Labor Hours]
I had to use a LOOKUPVALUE function to retrieve Job Qty Released because Job Qty Released "Does not relate with the other columns in the staging bar". And I think this is what is complicating this whole scenario.
When I grab the whole query from this second report and throw it in a STAT function in my first report to SUM by job, it doesn't work the same way. See image below. I'm thinking it's because the LOOKUPVALUE function is trying to pass Job Suffix as a parameter, but the first report does not have a Job Suffix column. What I'm actually trying to pass is the job suffix column value from the query I got from my second report. Is this not possible?

Here's my STAT function:
STAT(SUM,0,[Jobs.Job],SELECT (LOOKUPVALUE(0,[Jobs.Job],1,[Jobs.Job Suffix],SELECT [Jobs.Job],[CO Line Due Date: Min: Job Qty Released] from [All] WHERE [Jobs.Job Suffix]=%0)-[CO Order Date: Sum: Job Route Qty Completed])*[CO Create Date: Sum: Job Route Sched Run Labor Hours], [Work Centers.Work Center], [Jobs.Job], [Jobs.Job Suffix], [Job Route.Job Route Operation] FROM [ALL] WHERE [Jobs.Job] = %0 AND [Work Centers.Work Center] = 'SAW00')