Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Exclude Amounts from Total based on another field content in report

Posted on 2011-09-27
6
Medium Priority
?
204 Views
Last Modified: 2012-08-13
I will keep this simple. I am printing a report. The table used to print the report has 3 fields, pounds, price, and reject reason. Pounds are multiplied by price to arrive at Extended Cost. When printing the report, I total pounds and extended price. However, I need to exclude, from the totals, any record that has reject reason. I still want to print the record. However, it cannot be included in the totals. Could I look at the detail records as they are printing and change the value of any record with a reject reason to text so it will not be included in the total?
0
Comment
Question by:rodneygray
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 61

Accepted Solution

by:
mbizup earned 2000 total points
ID: 36713967
You can use a textbox at the bottom (footer section) of your report to do this.  The control source for such a total would be something like this:

= Sum([Pounds] * Abs("" & [RejectReason] = ""))

Use the actual field names as seen in your underlying table or query.

The result is a Sum of Pounds where there is no RejectReason and Zero for records where there is a reject reason.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36713970
The same approach can be applied to your other field...
0
 
LVL 1

Author Closing Comment

by:rodneygray
ID: 36714020
That worked perfectly. However, I cannot figure out what the last part of the formula does. Would you mind explaining it for me (and others)?
= Sum([Pounds] * Abs("" & [RejectReason] = ""))
0
Prepare for your VMware VCP6-DCV exam.

Josh Coen and Jason Langer have prepared the latest edition of VCP study guide. Both authors have been working in the IT field for more than a decade, and both hold VMware certifications. This 163-page guide covers all 10 of the exam blueprint sections.

 
LVL 1

Author Comment

by:rodneygray
ID: 36714061
I tired the same formula for the extension and the formula does not work. Can you see what I have done wrong?
=Sum([Price]*[pounds])*Abs("" & [RejectReason]="")
0
 
LVL 61

Expert Comment

by:mbizup
ID: 36714083
Sure - that's one of my favorite code tricks.

Explanation -

This is just comparison:

Abs("" & [RejectReason] = "")  = ""

It appends an empty string to RejectReason and compares it to an empty string.  If RejectReason is either Null or empty, the comparison is TRUE.  If it is populated the comparison is FALSE

True = -1  <-- the Abs takes the absolute value, returning 1
False =0

So the value being summed is either Pounds * 1 if the reason field is empty or Pounds * 0 if it is populated.

___

It looks like you've got the idea, but you need another set of parentheses so that you are summing the entire expression:

>> =Sum([Price]*[pounds])*Abs("" & [RejectReason]="")

Should be:

=Sum(([Price]*[pounds])*Abs("" & [RejectReason]="") )



0
 
LVL 61

Expert Comment

by:mbizup
ID: 36714092
An alternative syntax uses IIF, but I like the above method better.  

This is the same thing using IIF:

=Sum(IIF("" & [RejectReason]="", [Price]*[pounds], 0) )


0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
If you need a simple but flexible process for maintaining an audit trail of who created, edited, or deleted data from a table, or multiple tables, and you can do all of your work from within a form, this simple Audit Log will work for you.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question