473,387 Members | 1,904 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How do I use the sum and if functions together to count reponses in a given quarter?

I am trying to find the number of response types given for a survey question during a single quarter and post the count in an unbound field on a bound report. I have written the following expression that, in my mind, should work but I keep getting error messages:

=Sum(IIf(Eval[tblTableName].[FieldName]="5" And (DatePart("q",[SurveyDate])=2)),1,0)

My thinking is, I should get a count of all of the "5" responses in the named field that were received during the second quarter. Can you see what I'm doing wrong?
Jul 27 '10 #1
4 2206
Oralloy
988 Expert 512MB
What errors?
Jul 27 '10 #2
Stewart Ross
2,545 Expert Mod 2GB
Eval is not correct in this context - although as it is shown it is missing the left and right braces around its arguments - Eval(something), not Eval something.

If tblTablename.FieldName is not one of the fields in the recordsource of your report you cannot refer to it the way you are trying to do so. You will need to use a domain aggregate function such as DLookup, DSum or DCount to return the appropriate single value, sum or count respectively of the fields meeting whatever WHERE criteria you define. You cannot use an IIF within a DLookup, DCount and so on - you would need to consider how to set up a where clause for the domain function to filter the records as needed.

Example:

=DCount("FieldName", "tblTableName", "YourWhereClause")

We'd need to know a fair bit more about the fields etc involved and whether or not they are bound or unbound within your report if you want us to advise you about how to structure a Where clause to return the records for a particular quarter you are referring to.

-Stewart
Jul 27 '10 #3
It's an unbound text box. I read somewhere that it's not possible to use a query within a text box so I'm trying to accomplish the same end result with an expression.

So in your example
=DCount("FieldName", "tblTableName", "YourWhereClause")
could the WhereClause include the DatePart function?

Thanks for your help.
Jul 28 '10 #4
Stewart Ross
2,545 Expert Mod 2GB
Hi. The where clause in the DCount has to refer to one or more fields in the same table. As long as the field on which DatePart is operating ([SurveyDate] in your example) is within the table which DCount is looking at then yes indeed you can include the datepart component within the Where clause.

If the field called [SurveyDate] is not part of the same table, you will need to create a query which joins the relevant tables together so that all necessary fields are available to the DCount function when you call it.

-Stewart
Jul 28 '10 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Winston Smith | last post by:
Hi, PHP newbie here... I've been using static class functions as a means of grouping certain functions together (e.g. class::function() ). Anybody know if this carries a performance overhead...
15
by: Prabu | last post by:
Hi, I'm new to python, so excuse me if i'm asking something dumb. Does python provide a mechanism to implement virtual functions? Can you please give a code snippet also...:) Thanx in advance...
6
by: A | last post by:
Hi, How do you make use of nested functions in C++? I realize in C++ that everything must be declared first in a header file before implementation in a .cpp file. I tried to nest a method...
1
by: FZ | last post by:
Hi again all, I have another reporting question that I was hoping someone could help me with. I have a report that I have grouped into 3 groups: by year, by quarter, and by response type. I have...
6
by: Stijn | last post by:
Hi there, I have the following problem. At the moment I am creating an application that interfaces with several hardware modules via USB. Each of these devices has its own functionality and I...
47
by: Albert | last post by:
So structures are useful to group variables, so you can to refer to a collection as a single entity. Wouldn't it be useful to also have the ability to collect variable and functions? Ask K&R...
2
by: usmhot | last post by:
Sorry to sound beligerent, but this is hacking me off Can someone tell me why I can't access the XPath functions in an XSL document? I'm using XML Spy V4 and I've tried the following reference...
12
by: thegman | last post by:
Hi all, I'm trying to get list of JavaScript methods/functions in a script file in much the same a good text editor will, the difference being that I need to output it to a file or stdout, or some...
5
by: James | last post by:
Hello. I have a problem trying to get seperate image functions to work together. Starting with the img tag and associated html: <img src="image1.jpg" NAME="theImage" pbsrc="image1_lrg.jpg"...
5
by: shahtech02 | last post by:
Hi All, I want to get the record count for a given SQL Query in .Net without manipulating the given query. (other than count(*) ) Is there any method available in .Net to get the record count...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.