473,466 Members | 1,286 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Crosstab or Pivot Frustration

Hi

I have one table with the following design:
Fieldname Datatype
Region Text
Supply Number
Sales Number
Revision Number
Refused Number
SoldOut Number

I want to be able to report the data in the following format:
Total Region1 Region2 Region3 Region4
Supply
Sales
Revision
Refused
Soldout

I have been attempting this using crosstab queries and pivot tables to
no avail. I think I don't understand the concept. Can someone please
assis me?

Oct 31 '07 #1
3 1398

"Hansen" <he******@hotmail.comwrote in message
news:11*********************@o38g2000hse.googlegro ups.com...
Hi

I have one table with the following design:
Fieldname Datatype
Region Text
Supply Number
Sales Number
Revision Number
Refused Number
SoldOut Number

I want to be able to report the data in the following format:
Total Region1 Region2 Region3 Region4
Supply
Sales
Revision
Refused
Soldout

I have been attempting this using crosstab queries and pivot tables to
no avail. I think I don't understand the concept. Can someone please
assis me?
Your table structure needs normalization.

Region InformationType Datavalue
-------- ---------------- ---------
Region1 Supply 1
Region1 Sales 2
Region1 Revision 3
Region1 Refused 4
Region1 SoldOut 5
Region2 Supply 6
....

With this table structure the Cross tab wizard could build a query to
produce your the required output.
Oct 31 '07 #2
"Hansen" <he******@hotmail.comwrote in message
news:11*********************@o38g2000hse.googlegro ups.com...
Hi

I have one table with the following design:
Fieldname Datatype
Region Text
Supply Number
Sales Number
Revision Number
Refused Number
SoldOut Number

I want to be able to report the data in the following format:
Total Region1 Region2 Region3 Region4
Supply
Sales
Revision
Refused
Soldout

I have been attempting this using crosstab queries and pivot tables to
no avail. I think I don't understand the concept. Can someone please
assis me?
Well, I'll get you started with one approach. There are probably others.
It uses two queries.

The first UNION query restructures you data into a normalized layout:
SELECT Region, "Supply" AS Category, Supply AS Result FROM Table1
UNION
SELECT Region, "Sales" AS Category, Sales AS Result FROM Table1
UNION
SELECT Region, "Revision" AS Category, Revision AS Result FROM Table1
UNION
SELECT Region, "Refused" AS Category, Refused AS Result FROM Table1
UNION
SELECT Region, "SoldOut" AS Category, SoldOut AS Result FROM Table1;
The second CROSSTAB query uses the first query:
TRANSFORM Sum(Result) AS SumOfResult
SELECT Category
FROM Query1
GROUP BY Category
PIVOT Region;

You'll have to do some more work if you want to show "totals".

Fred Zuckerman

Oct 31 '07 #3
Thank you Fred.

Your approach has given me insight into crosstab queries and works
like a charm.

I was busy using case statements to select records by Region and then
populating unbound text boxes on the report. a Lot more work than this
approach!

Nov 1 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sotiris Rentoulis | last post by:
Dear friends, I wonder if exist a way to make crosstab queries in SQL Server like those in Access without "external" programming. Does the SQL Server supports the "TRANSFORM" SQL-extension? ...
3
by: Randy Harris | last post by:
I've been trying to construct a Crosstab query (mess pasted below) that would output all rows, even if the Value (a count) is 0. No matter what I do, it only returns rows that have matching...
2
by: Claus Haslauer | last post by:
Hi, I want to create a crosstab query that looks like this Date | Elevation 1 | Elevation 2 | ... ______________________________________________________________________ Date 1 | xx.y | xx.y...
14
by: Tina | last post by:
My employer tracks productivity/performance of clinicians (how much they bill) each week, its averages for the month, and the 6 months. These averages are compared to their expected productivity....
13
by: salad | last post by:
Operating in A97. I didn't receive much of a response conserning Pivot tables in Access. Pivot tables are nice, but a CrossTab will work for me too. Using a Pivot table, one is actually...
3
by: Jim Andersen | last post by:
Hi, Am using robvolks crosstab-procedure to generate a crosstab query. I get this result: Total A B C juli 455 1 107 347 okt 83 1 9 73 aug 612 1...
3
by: russellhq | last post by:
Hi, I'm fairly new to access and have a little trouble with a crosstab query I've setup. I have a main form where the user selects a project name and below in a subform, a crosstab query is...
4
by: mattlightbourn | last post by:
Hi all, I have a problem which has been driving me nuts. Crosstab queries! I have a database witch a few different tables to do with garment manufacturing. I have a table for a client...
11
ollyb303
by: ollyb303 | last post by:
Hello, I am using a dynamic crosstab report to track performance statistics for my company and I have hit a problem. I would like the option to track stats daily (for the last 7 complete...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
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...
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...
0
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,...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.