Solved

Formatting data in a crosstab query

Posted on 2014-03-14
5
355 Views
Last Modified: 2014-03-20
I have created a select query where I calculate the % of pupils working at a certain level in each subject.

I now want to create a crosstab query with the level as a row heading and subject as a column heading and display the % of pupils but although it is formatted as % in the select query and displays correctly in does not display this way in the crosstab query

Level      Art      Drama
      0.809836065573771      0.809836065573771
2      0.101639344262295      9.50819672131148E-02
3      8.85245901639344E-02      9.50819672131148E-02

Even though I got to properties and select format > percentage it does not seem to work.

Tricia
0
Comment
Question by:tmckeating
  • 3
  • 2
5 Comments
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39930573
Are you perhaps using the NZ( ) function anywhere in the query(s) that generate this?

When used in a query, the NZ( ) function will return a string, and when you try to format the string as %, in the query designer, it will not work.  If you use NZ( ), try wrapping it in a type conversion functions, something like cdbl(NZ([field name]))  and see if that works.
0
 

Author Comment

by:tmckeating
ID: 39931141
I am not using NZ anywhere in the query and adding cdbl does not appear to do anything.

Tricia
0
 
LVL 47

Accepted Solution

by:
Dale Fye (Access MVP) earned 250 total points
ID: 39931174
can you provide the SQL for the queries (multiple SQL Statements if nested) that generate these values.

What does the data look like before you do the crosstab?  Is it normalized like:

Level   Course    Pct
1          Art           0.809836065573771
1          Drama     0.809836065573771
2          Art           0.101639344262295
2          Drama    9.50819672131148E-02
3          Art           8.85245901639344E-02
3          Drama    9.50819672131148E-02

I normally prefer to use the query design grids formatting properties Query column formmatingbut on occasion will actually use the Format( ) function to force query output into a format that I'm not able to get with the query format parameter.  You might try using a format like:

format([Pct], "#0.0000%") in the query that creates the cross-tab
0
 

Author Closing Comment

by:tmckeating
ID: 39941931
I was using the formatting properties as you showed above but that did not work ...the format() function worked superbly. Thanks again for your help.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 39942221
Glad I could help.

You just need to make sure your understand that the Format( ) function returns a string, not a number, whereas using the Format property of the query affects the way the data is displayed, but will retain it's actual value.
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
MS Access Tables Linking 6 40
MS Access Order Smallest to Biggest Query Help 13 41
Restrict list data depending upon user name 3 20
Format a Field AFTER UPDATE 5 26
In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now