Solved

Formatting data in a crosstab query

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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Question has a verified solution.

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

I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

776 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