papadega3000
Registered User.
- Local time
- Today, 09:55
- Joined
- Jun 21, 2007
- Messages
- 80
I have a problem trying to sum a numeric column based off another column in the same table.
What I am trying to accomplish is to sum a numeric column if a corresponding column is Not Null.
I have uploaded my sample DB that to illustrate my problem. The query I am testing with is called Query1 and I am looking at summing point values from the task table grouped by the test case those tasks are in. I can easily sum the total number of points for each test case. But when I add another field to the query to sum the point values of the task in the test case that have a date entered into its corresponding date field it will not sum them correctly.
The result I get is the same sum total is shown for all three fields in the query.
I have tried several attempts at making criteria for this to work but nothing seems to work the way I want it too.
Here are my attempts:
IIf(Not (Sum([Task].[Points]))=IsNull("Attempted_Actual"),Sum([Task].[Points]),0)
IIf(Not (Sum([Task].[Points]))=IsNull("Completed_Actual"),Sum([Task].[Points]),0)
Not IsNull("Attempted_Actual")
Not IsNull("Completed_Actual")
My question is:
Is it possible to do want I want all in one select query or would this be something to code in a VBA module and then just call that module in a report?
My plan was to do this all in a query then build a report to display this query.
I have attached my dummyDB file and you can look at the Test_Case Table and expand each test case to see the data I have populated.
Any guidance would be appreciated.
Thanks,
What I am trying to accomplish is to sum a numeric column if a corresponding column is Not Null.
I have uploaded my sample DB that to illustrate my problem. The query I am testing with is called Query1 and I am looking at summing point values from the task table grouped by the test case those tasks are in. I can easily sum the total number of points for each test case. But when I add another field to the query to sum the point values of the task in the test case that have a date entered into its corresponding date field it will not sum them correctly.
The result I get is the same sum total is shown for all three fields in the query.
I have tried several attempts at making criteria for this to work but nothing seems to work the way I want it too.
Here are my attempts:
IIf(Not (Sum([Task].[Points]))=IsNull("Attempted_Actual"),Sum([Task].[Points]),0)
IIf(Not (Sum([Task].[Points]))=IsNull("Completed_Actual"),Sum([Task].[Points]),0)
Not IsNull("Attempted_Actual")
Not IsNull("Completed_Actual")
My question is:
Is it possible to do want I want all in one select query or would this be something to code in a VBA module and then just call that module in a report?
My plan was to do this all in a query then build a report to display this query.
I have attached my dummyDB file and you can look at the Test_Case Table and expand each test case to see the data I have populated.
Any guidance would be appreciated.
Thanks,