Report – Can you calculate the sum of a field that is based off an iif function? (1 Viewer)

Venus

Registered User.
Local time
Today, 17:43
Joined
Dec 11, 2013
Messages
15
I’ve created a query that contains an “iif” function and have created a report based off this query. I am struggling to find a way to calculate the sum of the field that uses the iif function in my report


Basically, I have my Courses table which contains a list of courses taught, the instructor name, how many credits the course is worth etc. and I have a Stipend Amount table which is linked to my Courses table through the number of credits the course is worth (Stipend amount is based on number of credits). Only courses taught outside of a regular teaching load get paid a stipend, so I only need these stipend amounts to show up if the “Load” field in the Course table reads “No”. If the “Load” field reads “Yes” then no Stipend is paid. I’ve created a query with a Stipend field that contains the following:
IIf([tbl_Courses].[Load]="yes","N/A",[Tbl_Stipend_Amount].[Stipend_Amount])
The query worked great, and now I’ve created a report that groups the courses by Instructor name to show a list of all courses taught by an instructor. When I try to add a text box to calculate the sum of the Stipend for all courses taught by an instructor: =sum([Stipend]) I get the error message “Data Type Mismatch in Criteria Expression”. Is it possible to calculate the sum of a field that uses an iif function?
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:43
Joined
Aug 30, 2003
Messages
36,132
I suspect it's because you've mixed text and numeric values. Try

IIf([tbl_Courses].[Load]="yes",0,[Tbl_Stipend_Amount].[Stipend_Amount])
 

Venus

Registered User.
Local time
Today, 17:43
Joined
Dec 11, 2013
Messages
15
It worked! Thank you so much. You just made my day!
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 15:43
Joined
Aug 30, 2003
Messages
36,132
Happy to help!
 

Users who are viewing this thread

Top Bottom