I'm trying to use a search form solely for setting a condition in a calculated field in a tabular report.
I have a Job_Table that houses information about our Jobs (Job_Number is the ID for this table). I have a TimeEntry_Table that houses Job_ID, Date, And Hours for our employee timesheet. The datapage uses Job_Table as the source.
I have a calculated field that queries to the TimeEntry_Table and sums up the Hours for each Job. This works. However, now I am trying to add a date range to this. I've been trying to use two virtual fields in the search form to set parameters. If the user leaves these blank, it'll just sum up all of the hours matching the Job_ID. But, if they enter in dates in the two virtual fields, I am trying to use these in my Calculated Field.
CASE WHEN [@DateFrom] IS NOT BLANK AND [@DateTo] IS NOT BLANK
SELECT Sum(Hours) FROM TimeEntry_Table WHERE Job_ID = Job_Number AND Date BETWEEN [@DateFrom] AND [@DateTo]
ELSE
SELECT Sum(Hours) FROM TimeEntry_Table WHERE Job_ID = Job_Number
END
To start off the CASE statement, I'm not sure if I should use the parameter name or cbViritualParam. It seemed neither worked. I am not sure if you can check to see if parameters or virtual fields are empty from the search form. Next, you can see the BETWEEN condition. This is where I am trying to enter in the dates from the virtual fields to filter the number of records that are summed up.
You can post now and register later.
If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.
Question
kpcollier
I'm trying to use a search form solely for setting a condition in a calculated field in a tabular report.
I have a Job_Table that houses information about our Jobs (Job_Number is the ID for this table). I have a TimeEntry_Table that houses Job_ID, Date, And Hours for our employee timesheet. The datapage uses Job_Table as the source.
I have a calculated field that queries to the TimeEntry_Table and sums up the Hours for each Job. This works. However, now I am trying to add a date range to this. I've been trying to use two virtual fields in the search form to set parameters. If the user leaves these blank, it'll just sum up all of the hours matching the Job_ID. But, if they enter in dates in the two virtual fields, I am trying to use these in my Calculated Field.
CASE WHEN [@DateFrom] IS NOT BLANK AND [@DateTo] IS NOT BLANK SELECT Sum(Hours) FROM TimeEntry_Table WHERE Job_ID = Job_Number AND Date BETWEEN [@DateFrom] AND [@DateTo] ELSE SELECT Sum(Hours) FROM TimeEntry_Table WHERE Job_ID = Job_Number END
To start off the CASE statement, I'm not sure if I should use the parameter name or cbViritualParam. It seemed neither worked. I am not sure if you can check to see if parameters or virtual fields are empty from the search form. Next, you can see the BETWEEN condition. This is where I am trying to enter in the dates from the virtual fields to filter the number of records that are summed up.
Nothing is showing up with my workflow.
Any help is appreciated.
Link to comment
Share on other sites
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.