I am new to this and not to brag, but I'm very impressed at the progress that I have made considering that I have NO formal tutoring on any kind of computer program. It has all be trial and error for me. Anyway, I have created a database for my work. I am satisfied with it except I am stuck on a report. I have a table with:
Fields:
customer id
vendor name
date
invoice
sales
I need to have a report that lists every customer and every vendor with sales columns that show YTD this year, YTD last year, Current Mo this year, and Current Month last year.
I have succeeded in making the different queries but cannot seem to get all of the information in one querie. I did the sub report thing, but it shows the information in "groups" instead of straight across:
i.e.: - cust 1 vendor 1 ytd
-
cust 1 vendor 1 ytd
-
cust 1 vendor 1 cm
-
etc.
I want it to look like this: - cust 1 vendor 1 ytd ytd cm cm
-
vendor 2 ytd ytd cm cm
etc.
CAN ANYONE HELP?!?!?!?!
10 4043 NeoPa 32,556
Expert Mod 16PB
Can you post the queries you have already.
Can you explain why there are two ytd values shown?
Something like the following should work
Assuming table structure as follows:
VendorName
SalesDate
SalesAmount -
SELECT VendorName,
-
Sum(IIf(Year([SalesDate]) = Year(Date()), [SalesAmount],0)) As CurYTD,
-
Sum(IIf(Year([SalesDate]) = Year(Date())-1, [SalesAmount],0)) As PrevYTD,
-
Sum(IIf(Year([SalesDate]) = Year(Date()) And Month([SalesDate]) = Month(Date()), [SalesAmount],0)) As CurMth,
-
Sum(IIf(Year([SalesDate]) = Year(Date())-1 And Month([SalesDate]) = Month(Date()), [SalesAmount],0)) As PrevMth
-
FROM TableQueryName
-
GROUP BY VendorName;
-
Mary
NeoPa 32,556
Expert Mod 16PB
Something like the following should work
Assuming table structure as follows:
VendorName
SalesDate
SalesAmount -
SELECT VendorName,
-
Sum(IIf(Year([SalesDate]) = Year(Date()), [SalesAmount],0)) As CurYTD,
-
Sum(IIf(Year([SalesDate]) = Year(Date())-1, [SalesAmount],0)) As PrevYTD,
-
Sum(IIf(Year([SalesDate]) = Year(Date()) And Month([SalesDate]) = Month(Date()), [SalesAmount],0)) As CurMth,
-
Sum(IIf(Year([SalesDate]) = Year(Date())-1 And Month([SalesDate]) = Month(Date()), [SalesAmount],0)) As PrevMth
-
FROM TableQueryName
-
GROUP BY VendorName;
-
Mary
OK smartie.
So I missed the bit of the explanation where the current & previous stuff was detailed. I was trying to go on the example that was shown which threw me off the scent a bit :D.
Well spotted.
But!
Not to be outdone I went through your SQL with a fine-tooth comb, only to find it was perfect :(
OK smartie.
So I missed the bit of the explanation where the current & previous stuff was detailed. I was trying to go on the example that was shown which threw me off the scent a bit :D.
Well spotted.
But!
Not to be outdone I went through your SQL with a fine-tooth comb, only to find it was perfect :(
Well of course it was, when do I ever make mistakes. Shh!
NeoPa 32,556
Expert Mod 16PB
Well of course it was, when do I ever make mistakes. Shh!
Never ask a question you don't know the answer to!
(I suppose you didn't huh? hence the Shh :D)
Thanks a lot. I'll try this and let you know how it works. Although, it sounds like you are pretty confident.
[quote=NeoPa]Never ask a question you don't know the answer to!
(I suppose you didn't huh? hence the Shh :D)[/QUOTe
Can I do this in the report controls?
Can I do this in the report controls?
You can make this query the Record Source of your report if that's what you mean. I'm not sure what you are asking in your question.
Mary
You can make this query the Record Source of your report if that's what you mean. I'm not sure what you are asking in your question.
Mary
Got it. It worked great. The only problem is that on the ytd column for previous year, it showed all sales for the entire year instead of just up to the current month. I worked that out. My only other question is...The report is showing customers that have had any sales at any time during the year for last year or this year even if the amounts for the time period is $0.00. How can I illiminate the customers with no sales at all for this time period without affecting the other customers that may have $0.00 values in just some instances?
NeoPa 32,556
Expert Mod 16PB
If you only want those customers that have had 'some' sales in the specified period (regardless of the value of those sales), then an INNER JOIN with the sales data (I don't think we know what/where that is stored) would do you.
If you want only those customers whose sales exceed 0 in the specified period, then you put something like the following in the WHERE clause : Sign in to post your reply or Sign up for a free account.
Similar topics
by: Ken Fine |
last post by:
I want my application to maintain a directory tree based on months and
years, e.g.:
2004
January
file
file
file
February
file
|
by: rong.guo |
last post by:
Greetings!
I am now doing one type of analysis every month, and wanted to creat
table names in a more efficient way.
Here is what happens now, everytime I do the analysis, I will create a...
|
by: Donna Sabol |
last post by:
First, I should start by saying I am creating a database to be used by
some very impatient, non-computer literate people. It needs to be
seameless in it's operation from their point of view. I...
|
by: poohnie08 |
last post by:
i have a excel spreadsheet showing staff name, date,work hour, ot
hour, slot1, slot2, slot3, slot4 and others). The "()" will keep
repeating from day 1 until end of month.
eg in excel spreadsheet,...
|
by: Abdhul Saleem |
last post by:
Hi,
I am recieving error ActiveX component can't create object in the following
line in the asp page.
set ExcelApp = CreateObject("Excel.Application")
Previously this code was working fine....
|
by: bruce24444 |
last post by:
I have a database which assigns warranty claims to people with a main screen showing number of files assigned to each person. The number assigned shows day, week, month and year numbers so they can...
|
by: Paul H |
last post by:
I want to base a form on a crosstab query. The query shows statistics
for a user defined period. The column headings will look something
like this:
ClientID Month01 Month02 Month03 etc..
...
|
by: TG |
last post by:
Hi!
I have an application in which I have some checkboxes and depending
which ones are checked those columns will show in the datagridview
from sql server or no.
After that I have 2 buttons:...
|
by: alhomam |
last post by:
hi all
i have a table with many columns
and i need to create a report that the user can select the columns he
needs to show in the report.
is it possible?
thanks
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
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: 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,...
| |