Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Percent Field in Cross-Tab Post Reply Post New Topic
Author Message
merv
Newbie
Newbie
Avatar

Joined: 15 Oct 2007
Online Status: Offline
Posts: 10
Quote merv Replybullet Topic: Percent Field in Cross-Tab
     Posted: 01 Nov 2007 at 12:24pm

I created a cross-tab report with 2 column (col1 & col 2).  Is it possible for crystal to calculate the percent of  (col2/col1) in a new col.

  col 1 col 2 col 3 (col 2/col 1)
A 500 450 90%
B 60 20 33%
C 75 70 93%
D 66 63 95%
E 99 21 21%
F 25 15 60%
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 01 Nov 2007 at 9:29pm
Hi - I give this exact example in my new book. I'm going to give you the overview here and you might be able to get it working. But to be honest, it's pretty complicated and there are a few pages of descriptions and explanations in the book. Also, I''m on vacation right now and didn't bring the book with me. So I'm going from memor yhere. If you can't get it working, then you should pick up a copy of the book.

Here's how it works: You have to have a formula that creates a global array for each column. Modify the cell in the cross-tab so that you attach a formula to one of the properties and that formula populates the array with the CurrentValue() function. Use the row/column value to determine which element in the array to populate.

Once you get to the last row, the first two columns in the array will be populated and then you can do the % calculation. Create a new formula doing the % calculation and attach it to the ToText property of the cell in the last column.

Again, this is a bit vague b/c I don't have my book with me to reference, but even if I did, it's too complicated to explain perfectly in a forum post. So hopefully, this will get you going in the right direction. If not, the book is a little more than $30 on Amazon and it will be the best $30 you spent. 

You can find out more about my books at Amazon.com or reading the Crystal Reports eBooks online.


Edited by BrianBischof - 28 Mar 2008 at 9:45am
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
merv
Newbie
Newbie
Avatar

Joined: 15 Oct 2007
Online Status: Offline
Posts: 10
Quote merv Replybullet Posted: 02 Nov 2007 at 6:13am
Thanks Brian, 

I'm assuming you're referring to the "Crystal Reports Encyclopedia Volume 1" book.  I need to get this done by next week is your book being sold at any bookstores in NY.  I don't think I will get it in time if I ordered it online.



Edited by merv - 02 Nov 2007 at 7:07am
IP IP Logged
BrianBischof
Admin Group
Admin Group
Avatar

Joined: 09 Nov 2006
Online Status: Offline
Posts: 2458
Quote BrianBischof Replybullet Posted: 02 Nov 2007 at 7:19am
Yes, Borders has it in stock at most of their stores and keeps it in their warehouse. The PROBLEM is that they have all the biblio info wrong (title, author, etc.) and I've been calling to get them to correct it in their computer's database. But it hasn't happened yet. I'm pretty upset about this. So in my Borders, I can pull it up on their computer, the title is wrong and it says "not published yet', but when I go to the CR section of the store (by databases), then there it is right next to my CR.NET 2003 book. That really sucks. So I suggest that you call the store and ask them to do a physical check for the book (look for the bright green binding - it's pretty obvious) and not rely upon what their computer says. 
Please support the forum! Tell others by linking to it on your blog or website:<a href="http://www.crystalreportsbook.com/forum/">Crystal Reports Forum</a>
IP IP Logged
merv
Newbie
Newbie
Avatar

Joined: 15 Oct 2007
Online Status: Offline
Posts: 10
Quote merv Replybullet Posted: 02 Nov 2007 at 11:34am
Thanks
IP IP Logged
reispedro
Newbie
Newbie


Joined: 26 Mar 2008
Location: Portugal
Online Status: Offline
Posts: 7
Quote reispedro Replybullet Posted: 28 Mar 2008 at 9:18am
Hi,
 
I've got exactly the same problem, and i dont have access to the book, can you give me some guidelines to solve this issue ?
IP IP Logged
merv
Newbie
Newbie
Avatar

Joined: 15 Oct 2007
Online Status: Offline
Posts: 10
Quote merv Replybullet Posted: 31 Mar 2008 at 8:39am

I didn't have time to try the sample from the book.  So I made a query to perform the calculation and linked in the data using a subreport

IP IP Logged
reispedro
Newbie
Newbie


Joined: 26 Mar 2008
Location: Portugal
Online Status: Offline
Posts: 7
Quote reispedro Replybullet Posted: 01 Apr 2008 at 4:55am

Hi,

Ok , so you calculate this field on a subreport right ?

Can you be more specific, about the way you link the subreport to the chart.

 

IP IP Logged
merv
Newbie
Newbie
Avatar

Joined: 15 Oct 2007
Online Status: Offline
Posts: 10
Quote merv Replybullet Posted: 03 Apr 2008 at 6:06am

I’m not sure if you’re referring to a graph or cross-tab when you say chart but I used a cross-tab to display my results.  I use MS Access for the source of my data.  You can either create a query in MS Access or use the command option to create a SQL statement that will give you the results you desire.

 

 

col 1

col 2

col 3 (col 2/col 1)

A

500

450

90%

B

60

20

33%

C

75

70

93%

D

66

63

95%

E

99

21

21%

F

25

15

60%

 

 

I used this new query to create a cross-tab report.  If you’re original report is broken down into groups you can add that information to the new query because you will need it to link the data together when you insert it as a subreport.  After you’ve created the new report you can save and close that file.  Open you original report, choose insert subreport select the report you recently created and then drop it onto your report.  You can use the link tab to link the reports together if it’s broken into groups.  I hope this helps

IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum