Sunday, February 05, 2012   
 Search   
 

http://www.foxfirereporting.com
Register  Login  
Forums  
      
 Forums    
SearchForum Home
  Support  Foxfire! 6.0x Support  Report that fil...
 Report that filters based upon results of another report?
 
 8/23/2007 7:40:46 AM
uberstein
12 posts


Report that filters based upon results of another report?
How would I go about (using FF 6.06) selecting just from a limited number of invoice numbers, say those with non-zero balances, and then filtering it further from there? I know this is essentially a nested select, but I was wondering if there is a way to get around that limitation of FoxFire 6.

Essentially, what I'd like to do could be two reports. The first generates the list of invoices with non-zero balances, the second only looks at that list of numbers and does further filtering on only the lines with those invoice numbers (there are usually several, invoice number is NOT a unique number or primary key).

I know I'm not asking this correctly. The way the database in question is structured, it makes it difficult to explain.

There are several database records for each invoice # (They are the "transactions" for that invoice). The field that I am basing my filter upon (obalance) is always zero for most of these records. But I still want ALL of the records for a given invoice number if ONE of the records for that invoice number has a non-zero obalance field.

So the problem becomes if I filter for non-zero obalance, I lose the other records I need in the report for the given invoice number.

I'm trying to figure out how to do this in Foxfire. It seemed like the Union button in the Filter section might help, but I'm not sure if union is what I want.

If I could just run two reports and have the second base its results upon the results of the first report that generates just the list of invoice #s with non-zero obalance, it'd work.

The database in question is an SQL database running in Microsoft SQL Server 2005 Standard.

Is there any way to do this?

Am I making any sense at all? :-)

Thanks for any help.


 8/23/2007 8:41:58 AM
uberstein
12 posts


Re: Report that filters based upon results of another report?
OK after some fiddling around with the SQL Expression Builder, I was able to get it to work, but I still have to push the ignore button twice on two errors (Similar to the problem I was having in an above post titled "Dateadd.prg not found") but the errors are syntax errors instead of .prg not found errors.

Regardless, it works after ignoring two syntax errors, I get the desired output. So making headway. Now I'm trying to figure out why I'm getting the syntax errors.

The expression I ended up filtering ACCTSTATUS.BILLNO (which is the Invoice Number) against in the SQL Expression Builder box was:
SELECT ACCTSTATUS.BILLNO AS BILLNO
FROM [BILLED] ACCTSTATUS WHERE ACCTSTATUS.OBALANCE <> 0.00

The Filter reads "Acctstatus Invoice Number [IS] [IN THE LIST]
(SQL Expression Builder Box):
SELECT ACCTSTATUS.BILLNO AS BILLNO
FROM [BILLED] ACCTSTATUS WHERE ACCTSTATUS.OBALANCE <> 0.00

BILLED is the name of a table, and Acctstatus is tha table's alias.

I have tried making the SELECT ACCTSTATUS.BILLNO AS BILLNO
FROM [BILLED] ACCTSTATUS WHERE ACCTSTATUS.OBALANCE <> 0.00
expression into a data item, but when I do I get a different error when I filter against that data item, the error is:
[Microsoft][ODBC SQL Server Driver][SQL Server]Invalid column name 'ACCTSTATINVNONZERO'.
ACCTSTATINVNONZERO is the name of the data item with the expression.

 8/23/2007 10:19:42 AM
uberstein
12 posts


Re: Report that filters based upon results of another report?
Aha I got it. Making the Data Item a Subquery (which I did by accident, I did not know you could make subquery data items in Foxfire) solved the problem. I changed the data item to:

ACCTSTATUS.BILLNO IN (SELECT ACCTSTATUS.BILLNO AS BILLNO
FROM [BILLED] ACCTSTATUS WHERE ACCTSTATUS.OBALANCE <> 0.00)


which made it a subquery, and then just added the subquery data item to my list of filters.

I had no idea about subqueries. This will make Foxfire so much more useful.


 8/23/2007 3:16:08 PM
AndrewM
145 posts
www.aksel.com
5th


Re: Report that filters based upon results of another report?
Glad to hear it.

Also, one of the things we are putting into an update for Foxfire! 8.0 (likely 8.1)  is to be able to specify that the output of a report (when it goes to DBF or cursor) may be re-used for another report. When this happens, Foxfire! will automatically add the resulting cursor to the data dictionary so that when you run a request using it, it will rerun the originating request - kind of like a nested report.

 8/24/2007 11:40:30 AM
chick
17 posts


Re: Report that filters based upon results of another report?

It's worth point out that Andrew has indirectly answered your original question: Can I create a Request whose output can be used as input to a second Request? (I realized you solved this in a single Request by creating a calculated "sub-query" data item in the dictionary.

But the answer to your original question os yes, right now with v6.06 (and even earlier versions) you can chain reports so that the output of one becomes input to the next (and the chain can contain unlimited Requests).

The trick is to decide on a structure for the intermediate table (the one that will pass the data from the first Request to the second) and define those items in the Foxfire! data dictionary. The name you specify in the result name on the first page of the existing field would be used in the data item expression of each new item's definition. You will specify the name of the intermediate table in the expression for each new data item.

Then create the first Request with the filter conditions that identify the records you want to process in the second Request. Specify that the output of the first Request goes to a table with the name you chose for the intermediate table, and choose those fields you need to process the second Request. 

Next, define the second Request using the new data items. You may have further filtering on the intermediate table, but you should have all the records you need for that second Request.

I realize you don't need to solve the original problem, but this may come in handy in other situations.

What Andrew was referring to when he discussed v8.1 was an enhancement that would automatically add the intermediate table's data items to the dictionary to save several steps.

I'm glad you've found ways to make Foxfire! more useful for you.

Would you be willing to write up a set of simple instructions for creating a sub-query item that we can post to our forums for future readers?

Also, I think you would be very pleased to review the enhancements in v8+ You can download a free trial copy and convert your v6.06 app very easily to try it out for 30 launches within 60 days.

 

  Support  Foxfire! 6.0x Support  Report that fil...
   
SearchSearch  Forum HomeForum Home     
 Links    
   
  
Downloaded from DNNSkins.com