Solved

Formatting data in a crosstab query

Posted on 2014-03-14
5
351 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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

762 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