473,394 Members | 1,951 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,394 software developers and data experts.

How to show zero values in budget v actual query

I have a database that contains a series of budgets for different construction projects in separate tables and a master table for expenses in another table. I am trying to develop a 'budget v actual' query that can be output to a report for each project. I have created a separate query for 'budget' and a query for expenses for each project. I am trying to now develop a query that would pull from each of the foregoing that would show 'budget' v. 'actual'. However, if any of the budget line items or expenses line items are $0, then they do not appear in either Query. I need all budget line items to appear even if the budget is $0 and all expense line items to appear even if expenses to date are $0. Thanks in advance!
Jun 25 '12 #1
9 2246
Rabbit
12,516 Expert Mod 8TB
Use an outer join instead of a inner.
Jun 25 '12 #2
Ok. Thanks. That works! Now, how do I have the Query show $0 where there are no expenses to date for the budget line item. I want the report to show $0 when there are no expenses to date.
Jun 25 '12 #3
Rabbit
12,516 Expert Mod 8TB
Use the Nz() function to convert the nulls to 0.
Jun 25 '12 #4
I must be a "nube". Can't seem to get this to work. I'm trying to get "SumofTotalInvoiceAmount" to show $0 when there are no expenses to date. How would I modify the SQL?

Here is the SQL:

Expand|Select|Wrap|Line Numbers
  1. SELECT [Budget - 151 - Tower Road Query].BudgetCode, [Budget - 151 - Tower Road Query].BudgetCodeName, [Budget - 151 - Tower Road Query].OriginalBudget, [Budget - 151 - Tower Road Query].CurrentProjectedBudget, [151ExpensestoDate].SumOfTotalInvoiceAmount
  2. FROM [Budget - 151 - Tower Road Query] LEFT JOIN 151ExpensestoDate ON [Budget - 151 - Tower Road Query].BudgetCode = [151ExpensestoDate].BudgetCode
  3. GROUP BY [Budget - 151 - Tower Road Query].BudgetCode, [Budget - 151 - Tower Road Query].BudgetCodeName, [Budget - 151 - Tower Road Query].OriginalBudget, [Budget - 151 - Tower Road Query].CurrentProjectedBudget, [151ExpensestoDate].SumOfTotalInvoiceAmount;
Jun 25 '12 #5
Rabbit
12,516 Expert Mod 8TB
Use the Nz() function to convert the nulls to 0.
Expand|Select|Wrap|Line Numbers
  1. Nz([151ExpensestoDate].SumOfTotalInvoiceAmount, 0)
Also, as a side note, I don't know why you're using a group by when you're not running an aggregate.
Jun 25 '12 #6
Thanks for all your help on this.

I eliminated the group by and modified the SQL as indicated below. Now I only get results for budget line items that have expenses to date.

SELECT [Budget - 151 - Tower Road Query].BudgetCode, [Budget - 151 - Tower Road Query].BudgetCodeName, [Budget - 151 - Tower Road Query].OriginalBudget, [Budget - 151 - Tower Road Query].CurrentProjectedBudget, [151ExpensestoDate].SumOfTotalInvoiceAmount
FROM [Budget - 151 - Tower Road Query] LEFT JOIN 151ExpensestoDate ON [Budget - 151 - Tower Road Query].BudgetCode = [151ExpensestoDate].BudgetCode
WHERE ((([151ExpensestoDate].SumOfTotalInvoiceAmount)=Nz([151ExpensestoDate].[SumOfTotalInvoiceAmount],0)));
Jun 25 '12 #7
Rabbit
12,516 Expert Mod 8TB
When did I say to use the WHERE clause? You only use the WHERE clause when you're trying to filter out records. What you want to do is display them differently. The SELECT clause is what controls how something is displayed.
Jun 25 '12 #8
Right you are. Moved Nz to SELECT and it works perfectly. Thanks so much for your help. Cheers!
Jun 25 '12 #9
Rabbit
12,516 Expert Mod 8TB
No problem.
Jun 25 '12 #10

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

Similar topics

2
by: RBohannon | last post by:
I have a report with most fields populated by a query. However, some of the fields are variable in such a way that their values cannot be queried from a table. At present the values for these...
4
by: David Peach | last post by:
Hello, hope somebody here can help me... I have a query that lists defects recorded in a user defined date range. That query is then used as the source for a Cross Tab query that cross-tabs count...
5
by: Randy Harris | last post by:
How can I report an average of non zero values? If the values are: 5, 0, 6, 0, 4 I would like the result 5 (15 / 3), not 3 (15 / 5) Thanks for any help...
19
by: bdt513 | last post by:
I am trying to extract the values from a query using VBA. Specifically, I want to concatenate all the values of the "rosEmail" field from query "qselRosterEmailList" into one string (strEmails). I...
1
by: Prabhudhas Peter | last post by:
Hello, Need an easy way to Display the property values of an object (dynamically) ie I need to show the values of an Object in a rich text box. Background : We have a form, with a rich...
0
by: Jeff Boes | last post by:
I hope this helps someone else ... I had struggled some time ago with attempts to get a rank of values query to work, but then I gave up and set it aside. I had another reason to attack it, and in...
5
by: ravindarjobs | last post by:
hello friends, i am using ms access 2003. i have a form. and i want to show the results of a query output in the form. the query is dynamic. it changes often. for this purpose data grid...
8
by: cppquester | last post by:
I am forced to work with a char* buf; I allocate memory and then construct some data types in buf (several different at different locations of buf kind of struct alike) Sometimes all data...
0
VbaNewbee
by: VbaNewbee | last post by:
I have a form with a few filters. Once the user clicks "search button", the code first evaluates my filters, then shows the query results in a List Box" titled backschedule. I have a few text...
15
by: Michael R | last post by:
Hello forum! I have this question: I have a query with a column that uses this criteria: (IIfCustomerType()<>3,fCustomerType()) where fCustomerType() is a function result. But this...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.