Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Percentage of total in crosstab Post Reply Post New Topic
Author Message
Pam.1980
Newbie
Newbie


Joined: 06 Aug 2009
Online Status: Offline
Posts: 12
Quote Pam.1980 Replybullet Topic: Percentage of total in crosstab
     Posted: 18 May 2011 at 12:47pm
Hello,

This seemed easy enough but I am struggling and would really appreciate some help.

I am trying to create a crosstab for how many days it took to complete an order. These are the formulas I created (the first part is the name of the formula):

1) days took to close - Date difference in days (d) between date ordered and date closed
2) < 20 - if {@days took to close) < 20 then 1
3)< 40 - if {@ days tool to close) >= 20 and {@ days tool to close) <= 40 then 1
4)> 90 - if {@ days tool to close) > 90 then 1
5) {@<20} + {@<40} + {@>90}

In the cross tab I pulled in formulas 2, 3, 4, 5 mentioned above under the summarized fields (which displayed it as sum of ....)
Nothing at all in the rows and columns field in the cross-tab query expert.

In the report design, I manually added labels for the 3 different rows as: < 20, <40 and >90

So far so good. But tried a lot and I am not able to create percentages that work (tried so many different things).

There is no grouping in the report as there are no details. We just need a cross tab with totals and percentages. And a chart which I will worry about later.

Thank you,

Pam
IP IP Logged
freestylepunk
Newbie
Newbie
Avatar

Joined: 05 May 2011
Location: United States
Online Status: Offline
Posts: 13
Quote freestylepunk Replybullet Posted: 18 May 2011 at 3:26pm
Hi Pam, just wondering about your example... if you know that you will only have 3 columns inside the cross tab, why use a cross tab at all?
IP IP Logged
Pam.1980
Newbie
Newbie


Joined: 06 Aug 2009
Online Status: Offline
Posts: 12
Quote Pam.1980 Replybullet Posted: 19 May 2011 at 3:42pm
You are right. May I rephrase my query. Since a couple of items have changed.

Say I have a formula field to calculate the days between order taken and last time it was sent for closure. There are several dates for closure and only the last one in the table is relevant so the formula is:

1)maximum ({table.field}, table.id}) - {date created}

then I want:
2) total closed in given time range - can be down on report itself
3) count of days < 20 and the percentage of total
4) count of days > 20 and < 50 and the percentage of total

When I try to use the formula with maximum I am unable to do a count. What can I do to calculate #3 and # 4 above.

Thanks much
IP IP Logged
freestylepunk
Newbie
Newbie
Avatar

Joined: 05 May 2011
Location: United States
Online Status: Offline
Posts: 13
Quote freestylepunk Replybullet Posted: 25 May 2011 at 10:19pm
Hi Pam, when you write the formula for item number 1, you can add in some variables to store the count for the aging.
 
Eg:
shared numbervar shortaging;
shared numbervar longaging;
shared numbervar totalrecords;
local numbervar orderage := maximum ({table.field}, table.id}) - {date created};
 
if orderage < 20 then (
    shortaging := shortaging + 1
    totalrecords := totalrecords + 1
) else if orderage >= 20 and orderage < 50 then (
    longaging := longaging + 1
    totalrecords := totalrecords + 1
) else (
    totalrecords := totalrecords + 1
);
 
maximum ({table.field}, table.id}) - {date created};
 
At the footer, put a few formulas that declares and displays the count as well as calculating the percentages.
IP IP Logged
Pam.1980
Newbie
Newbie


Joined: 06 Aug 2009
Online Status: Offline
Posts: 12
Quote Pam.1980 Replybullet Posted: 28 May 2011 at 4:07am
Thank You 'freestylepunk'
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