Crosstab

B

Boon

Hello,

I am creating a crosstab query and would like to sort the column (or row) by
the column that is not displayed the data. Let me explain...

In a table I have field

Month_Name, Distribution_Name, Orders, Month_Num

The Month_Name looks like "Jan", "Feb",......
The Distribution_Name looks like "A","B",....
Orders is the number (125,650,...)
The Month_Num is 1,2,3,...

I want to build cross tab by putting Month_Name to column, Distribution_Name
to row and sum the orders (put it as value). Now the column in a result
datasheet does not sort in order (Jan, Feb, Mar), so I tried to sort by
Month_Num. But Access displays an error.

Is there a way to accomplish this or the work around on this?

Thank you,
Boon
 
J

John Spencer

You can specify the column names in the PIVOT clause of the query

Pivot Month_Name in ("Jan","Feb",...,"Nov","Dec")

If you are doing this in query design view, check the query properties
and enter the list of month names in order in the appropriate property.
I can't recall the property name at this time and I don't have access
to Access on this computer.

'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
The Hilltop Institute
University of Maryland Baltimore County
'====================================================
 
A

Access101

In query design view, click View, Properties.

In the resulting list, Description, Default View, Column Headings ...

Enter the following in Column Headings:

Jan;Feb;Mar;Apr ... etc.

Let me know if that solves it :)
 
K

KARL DEWEY

Rather than using Month_Name and Month_Num use your DateTime field like this --
PIVOT Format([YourDateTimeField], "mmm") IN("JAN", "FEB", "MAR", "APR",
"MAY", "JUN", "JUL", "AUG", "SEP", "OCT", "NOV", "DEC");
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top