Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 10116

Re: How to pass formula or field of one command object to another

$
0
0

Hi Francis,

 

You cannot simple insert a formula into the 'where' clause of a command object. You need to create command level parameters and then link the formula to this parameter using a Subreport.

 

Let's say you have a Main Report with Query 1. The Main Report lists the Min Time and Max Time using these formulas:

 

//Formula for Min Time

Minimum({Fromtime})

 

//Formula for Max time

Maximum({Totime})

 

Now, if you wish to filter another Query using the Min Time and Max Time derived from the above formulas, you need to create a Subreport. The Subreport's datasource will be Query 2. While in the "Add Command" window, you should have an option on the right to create parameters. Click on the button and create a parameter with the name 'From_Time'. Create a 2nd parameter with the with the name "To_Time".

 

Now, you should see the two parameters that you created in a list on the right. To insert the parameters into the Command object, you need to place the cursor in the where clause and double-click on the parameters.

 

As an e.g. : If your Query 2 is this:

 

Select * from some_table

where HOUR((TIME(ccsr.transaction_time))) >= AND HOUR((TIME(ccsr.transaction_time))) <

 

In the above query, you need to place the cursor after the '>=' sign and then double-click on the 'From Time' parameter. Do the same for the 'To_Time' parameter and your query should then look like this:

 

Select * from some_table

where HOUR((TIME(ccsr.transaction_time))) >= {?From_Time} AND HOUR((TIME(ccsr.transaction_time))) < {?To_Time}

 

You then need to go back to the Main Report and link the Main Report to the Subreport. Follow my earlier thread on how to link the formula to the Parameter inside the Subreport's datasource.

 

Hope this helps!

 

-Abhilash





Viewing all articles
Browse latest Browse all 10116

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>