473,803 Members | 3,463 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calculating values from subreports when one or more is null

52 New Member
I found something similar, but can't get it to work--maybe because I'm working in a report rather than a query?

I have a main report that has three subreports in it. Each subreport has a total for items in that subreport. If all three have entries, I can get a grand total, but if one or more doesn't, it just says error. I first tried using IIf/IsNull, but again, I get totals only when all three subreports have amounts. I then found nz, and tried that, but still I only get a total when all three have values. This seems like it just shouldn't be that complicated.

Here's what I have:

Expand|Select|Wrap|Line Numbers
  1. =Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Auction Items subreport]![Auction Total])+Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 1 subreport]![Party1 total])+Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 2 subreport]![Party2 total]) 
Can anyone tell me what I'm doing wrong? Or if there is an easier way of doing this? Thanks so much.
Jan 8 '08 #1
28 3673
Rabbit
12,516 Recognized Expert Moderator MVP
You have to give Nz a value to return if Null. Nz(FieldName, 0)
Jan 8 '08 #2
puppydogbuddy
1,923 Recognized Expert Top Contributor
I found something similar, but can't get it to work--maybe because I'm working in a report rather than a query?

I have a main report that has three subreports in it. Each subreport has a total for items in that subreport. If all three have entries, I can get a grand total, but if one or more doesn't, it just says error. I first tried using IIf/IsNull, but again, I get totals only when all three subreports have amounts. I then found nz, and tried that, but still I only get a total when all three have values. This seems like it just shouldn't be that complicated.

Here's what I have:

Expand|Select|Wrap|Line Numbers
  1. =Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Auction Items subreport]![Auction Total])+Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 1 subreport]![Party1 total])+Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 2 subreport]![Party2 total]) 
Can anyone tell me what I'm doing wrong? Or if there is an easier way of doing this? Thanks so much.
If your subtotals are in a header or footer (as opposed to a detail line), I think you have to use the keyword "Sum" for each subtotal as follows:

Expand|Select|Wrap|Line Numbers
  1. =Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Auction Items subreport]![Auction Total]))+Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 1 subreport]![Party1 total]))+Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 2 subreport]![Party2 total])) 
Jan 8 '08 #3
CindySue
52 New Member
Thanks for the suggestions, but I'm still not getting anything to work. I must still be missing something, or didn't understand exactly what I was supposed to do.

I tried three different things--
This, which includes the zero value:
Expand|Select|Wrap|Line Numbers
  1. =Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Auction Items subreport]![Auction Total],0)+Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 1 subreport]![Party1 total],0)+Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 2 subreport]![Party2 total],0) 
Which gives me a total when all three are present, but still an error if one or more is null.

I also tried this, which adds the sum function but uses no zero values:
Expand|Select|Wrap|Line Numbers
  1.  =Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Auction Items subreport]![Auction Total]))+Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 1 subreport]![Party1 total]))+Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 2 subreport]![Party2 total]))
which gives me zeros no matter what.

And this, which adds the zero value and uses sum
Expand|Select|Wrap|Line Numbers
  1. =Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Auction Items subreport]![Auction Total],0))+Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 1 subreport]![Party1 total],0))+Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Party 2 subreport]![Party2 total],0)) 
but this gives me zeros no matter what as well.

Does anyone see what I'm still doing wrong?
Jan 8 '08 #4
puppydogbuddy
1,923 Recognized Expert Top Contributor
I have a main report that has three subreports in it. Each subreport has a total for items in that subreport. If all three have entries, I can get a grand total, but if one or more doesn't, it just says error. I first tried using IIf/IsNull, but again, I get totals only when all three subreports have amounts. I then found nz, and tried that, but still I only get a total when all three have values.
In light of your statements above, there is something that you have not explained. the nz function, will not make numbers disappear if they were there, it will only substitute 0 when there is a null present. Which brings me to another thought ....Is it possible the columns are not null, but have spaces....in which case, you need to wrap each subtotal in the Val function.....so that it looks like this >>>>>Sum(Val(Nz (.............. )))
Jan 8 '08 #5
jaxjagfan
254 Recognized Expert Contributor
Instead of subreports have you tried using "Groupings" in your reports. It looks like you are reporting on "Bids". Make an aggegate query with the maximum number of columns you want to see - include the group by's, sum's, count's etc.

Then make a report based on this query.

This will allow you to include details in the groups necessary and will allow summaries in report, page, and group headers and footers. If one bid has 2 groups and the next has 5 it will not matter.

Try to handle exceptions before the report - it is normally easier to handle and easier to troubleshoot most of the time.
Jan 8 '08 #6
CindySue
52 New Member
Perhaps null is not the appropriate word. Maybe this will make it clearer. There are three tables--One called auction items, one called Party 1 and one called Party 2, which is identical in structure to Party 1. In all three tables is a field called winning bidder number and winning bid amount, among others. A single wining bidder number may appear multiple times in one, two or all three of the tables.

I have a report called Final Bid Sheets, based on a query of all winning bidder numbers that appear in any one or more of the three tables, and the only field on it is the winning bidder number, along with some text. I have a subreport for Auction Items, Party 1 and Party 2 that lists the winning bid amount field and another field or two and links to the main form by the winning bidder number. The first subreport shows all auction items matching the winning bidder number on the main form, grouped by Live or Silent and their amounts, then a total for those amounts. Party 1 shows the attendee number field and the amounts in the winning bid amount and then has a total, and Party 2 is identical to Party 1. I want to add the totals from each subreport, if there is one, so that there is a grand total on the main report, but if there are no entries for one or more of the subreports, I can't get the formula to work.

I've tried to attach a shot of what I'm trying to get, but I've never done that before, and I'm not sure I did it right. [IMG]c:\screenshot.j pg[/IMG]

Thanks again for trying to help.
Jan 8 '08 #7
puppydogbuddy
1,923 Recognized Expert Top Contributor
Perhaps null is not the appropriate word. Maybe this will make it clearer. There are three tables--One called auction items, one called Party 1 and one called Party 2, which is identical in structure to Party 1. In all three tables is a field called winning bidder number and winning bid amount, among others. A single wining bidder number may appear multiple times in one, two or all three of the tables.

I have a report called Final Bid Sheets, based on a query of all winning bidder numbers that appear in any one or more of the three tables, and the only field on it is the winning bidder number, along with some text. I have a subreport for Auction Items, Party 1 and Party 2 that lists the winning bid amount field and another field or two and links to the main form by the winning bidder number. The first subreport shows all auction items matching the winning bidder number on the main form, grouped by Live or Silent and their amounts, then a total for those amounts. Party 1 shows the attendee number field and the amounts in the winning bid amount and then has a total, and Party 2 is identical to Party 1. I want to add the totals from each subreport, if there is one, so that there is a grand total on the main report, but if there are no entries for one or more of the subreports, I can't get the formula to work.

I've tried to attach a shot of what I'm trying to get, but I've never done that before, and I'm not sure I did it right. [IMG]c:\screenshot.j pg[/IMG]

Thanks again for trying to help.

CindySue,

Your attachment was not accessible, but maybe this link will help:

http://support.microsoft.com/kb/208835
Jan 9 '08 #8
CindySue
52 New Member
As best I could understand, the Microsoft article actually only dealt with one subreport, and I have three. It provided a way to get a grand total from all the subtotals on that one subreport at the very end of the report, but not a way to include different subreports. It still, however, displayed an error when there were no entries in that particular subreport on that bidder number.

I thought about trying the query method suggested by jaxjagfan, but I'm not sure I understand how to do that and get all records. By aggreate, do I need to use union? And it won't matter that the fields aren't the same between the auction items and party tables?
Jan 9 '08 #9
puppydogbuddy
1,923 Recognized Expert Top Contributor
Try this. Chnged the order of the Val function. In Access, the order in which the function executes is important.....

=Val(Sum(Nz([Reports]![Final Bid Sheets]![Final Bid Sheet Auction Items subreport]![Auction Total],0)))+Val(Sum(N z([Reports]![Final Bid Sheets]![Final Bid Sheet Party 1 subreport]![Party1 total],0)))+Val(Sum(N z([Reports]![Final Bid Sheets]![Final Bid Sheet Party 2 subreport]![Party2 total],0)))
Jan 9 '08 #10

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

Similar topics

2
47857
by: Shaun | last post by:
Hi, I have a table called Bookings which has two important columns; Booking_Start_Time and Booking_End_Time. These columns are both of type DATETIME. Given any day how can I calculate how many hours are available between the hours of 09.00 and 17.30 so a user can see at a glance how many hours they have unbooked on a particular day (i.e. 8.5 hours less the time of any bookings on that day), can this be done with a query or do I have to...
0
2275
by: Kasp | last post by:
Hi there, I am trying to make an OLAP cube on a table having two columns (datetime, Number_of_times_an_event_occured). My dimension is time and I want to measure the Min and Max times an event occured over time. I have no problem in calculating Maximum occurance of events over time. However, I have some NULL values in my Number_of_times_an_event_occured column, due to which I don't see any result when I try to calculate
3
12826
by: Phil Sandler | last post by:
All, I have a table with start and end dates/times in it, and would like to be able to calculate the number of hours represented, accounting for overlapping records. Note that I am looking for an answer on HOW to do this--I don't necessarily need it to be written for me (although it would not go unappreciated!).
1
3248
by: Robin Munn | last post by:
I'm trying to calculate the default values of a column when I insert a row, based on the values of other columns. It's something I thought should be simple enough, but I can't seem to figure out how to do it. Here's a basic example of what I'm trying to do: CREATE TABLE money ( amount numeric NOT NULL, currency text NOT NULL DEFAULT 'USD', currency_per_usd numeric NOT NULL DEFAULT 1.00, usd_amount NOT NULL DEFAULT (amount /...
1
2512
by: Megan | last post by:
quick summary: i'm having problems trying to group fields in a report in order to calculate percentages. to calculate percentages, i'm comparing the results from my grouped fields to the totals. first, let me say that this is a really long post. i wasn't sure how much information/ background to provide, so i thought more was better than less. i tried to delineate certain areas so that it would be easy to peruse my posting and find...
1
2130
by: Don Sealer | last post by:
I have a report that includes 5 different subreports. I'd like to be able to open this report using a date function (Start Date and End Date). I'd like all five subreports to show the data from those dates. I have learned how to use this start/end function but I can't figure out how to use it with these subreports. Right now the report opens but asks for start/end dates for each of the five reports. Is there a way I can input one set of...
1
2471
by: josecruz | last post by:
I have created a main report, which is controlled with a date range parameter from the main form. The report has several sub reports, which perform calculations (counts and averages at the subreport level) based on the date range from the main form. My question or problem is that I have to calculate a percentage based on the result of two of the subreports. I created a text box on the main report and I enterd the following to calculate the...
3
1730
by: DeanL | last post by:
Hi all, I'm currently pulling out my already thin hair and need a little help if possible. I have an Access 97 db that is used to store inspection information for different regions. My report is meant to show the number of inspections done in each region and what ratings they achieved as below: Region Green Yellow Red NR Total
6
5458
by: Brett Barry: Go Get Geek! | last post by:
Hello, I have a main report with a Record Source, a DateToday table, that has the current Month and Year. I have about 60 queries, each pulling different data via ODBC, that I am creating subreports that go on the main report. The problem is that when I run the report the data shows on the screen but not the print preview. I am aware that the main report is not linked to the subreports because of the Link Master, Child Fields issue....
0
9703
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10548
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10316
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9125
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7604
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6842
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5500
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3798
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2970
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.