Hi, Experts

We are using CR 8.5 and MS SQL Server 2000

I have a crosstab in the report.

It looks like this

--------------------------------------------------------------------

| | Cat1 | Cat2 |Total |

--------------------------------------------------------------------

|Group 1|SubGroup1 |Sum(FLD1)|Sum(FLD1)|Sum(FLD1)|

| | |Sum(FLD2)|Sum(FLD2)|Sum(FLD2)|

| |--------------------------------------------------------|

| |SubGroup2 |Sum(FLD1)|Sum(FLD1)|Sum(FLD1)|

| | |Sum(FLD2)|Sum(FLD2)|Sum(FLD2)|

--------------------------------------------------------------------

|Group 2| ..... and so on

FLD1 - is number of total attempts to do smth.

FLD2 - is number of fails

I need instead of those fields show the Percentage of success so if FLD1= 100 and Fld2=3 I need to Display 97%

But I can't use totals in formula in Crosstab. Is there is a way to do it?

Thanks in advance.

We are using CR 8.5 and MS SQL Server 2000

I have a crosstab in the report.

It looks like this

--------------------------

| | Cat1 | Cat2 |Total |

--------------------------

|Group 1|SubGroup1 |Sum(FLD1)|Sum(FLD1)|Sum(F

| | |Sum(FLD2)|Sum(FLD2)|Sum(F

| |-------------------------

| |SubGroup2 |Sum(FLD1)|Sum(FLD1)|Sum(F

| | |Sum(FLD2)|Sum(FLD2)|Sum(F

--------------------------

|Group 2| ..... and so on

FLD1 - is number of total attempts to do smth.

FLD2 - is number of fails

I need instead of those fields show the Percentage of success so if FLD1= 100 and Fld2=3 I need to Display 97%

But I can't use totals in formula in Crosstab. Is there is a way to do it?

Thanks in advance.

I know how to do it If I only have fixed number of columns. The only advantage of crosstab is being dynamic. I can't use your method because I want to be able to enlarge my crosstab dynamicly based on data in the table.

You told that this is impossible in CR 8.5. Can I Do it with CR9 or 10?

--------------------------

| | Cat1 |~~~| CatN |Total |

--------------------------

|Group 1|SubGroup1 |Sum(FLD1)|~~~|Sum(FLD1)|S

| | |Sum(FLD2)|~~~|Sum(FLD2)|S

| |-------------------------

| |SubGroup2 |Sum(FLD1)|~~~|Sum(FLD1)|S

| | |Sum(FLD2)|~~~|Sum(FLD2)|S

--------------------------

|Group 2| ..... and so on

FLD1 identifies an attempt and is Counted in the Crosstab

FLD2 identifies a failure and is a boolean of some sort (yes/no, 1/0, etc..)

In the Format Cross-Tab dialogue box, click the <New Formula> button. You will create a formula that will help you calculate the successful attempts. It may look something like this:

@Successful_Attempts

If

{table.field2} = No//indicating that the 'Failed attempt' flag is no, therefore a 'Success'

Then

1

Else

0

Next, insert this new formula field (@Successful_Attempts) into the Summarized fields twice - once to be summed as the number of successful attempts and once to be averaged. Your report will look something like this (@Successful_Attempts is referred to as FLD3):

--------------------------

| | Cat1 |~~~| CatN |Total |

--------------------------

|Group 1|SubGroup1 |Sum(FLD1)|~~~|Sum(FLD1)|S

| | |Sum(FLD2)|~~~|Sum(FLD2)|S

| | |Sum(FLD3)|~~~|Sum(FLD3)|S

| | |Avg (FLD3)|~~~|Avg (FLD3)|Avg (FLD3)|

| |-------------------------

| |SubGroup2 |Sum(FLD1)|~~~|Sum(FLD1)|S

| | |Sum(FLD2)|~~~|Sum(FLD2)|S

| | |Sum(FLD3)|~~~|Sum(FLD3)|S

| | |Avg (FLD3)|~~~|Avg (FLD3)|Avg (FLD3)|

--------------------------

The downside is that you can't really format the average to look like a true percentage. It will come out looking like .97 instead of 97%. The upside is that you can basically calculate percentages at the column level.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.

1) Create groups as you have

2) Create Column Labels

3) Create formulas that will be placed in the detail section of the report. These formulas will be something like:

@Cat1_Fld1

If

Category = Cat1

Then

FLD1

Else

0

Based on your example, you'll need to create 4 formulas: Cat1_Fld1, Cat2_Fld1, Cat1_Fld2 and Cat2_Fld2. Each formula will be similar to the one shown above.

4) Right-click on each of these formulas--once they're in the detail section--and Insert Summary. You're going to Sum the values (assuming FLD2 and FLD2 have numeric values) both the subgroup and the primary group.

5) Hide or suppress the detail section.

6) Create two formulas at the subgroup level, each of which will calculate the percentage for its respective column. Each formula will look something like this:

@Cat1_subgroup_percentage

If

Sum(@Cat1_Fld1,subgroupfie

Then

((Sum(@Cat1_Fld1,subgroupf

Else

0

7) Next you'll create formulas for the Row totals at the subgroup level. The row totals formulas will look like this (alternate, you can just right-click on the Fld1 and Fld2 fields and Insert summary in the appropriate group footers):

@Subgroup_fld1_row_total

//Assuming that there are only two categories

//you can simply take a sum of FLD1, which will contain values

//for each category

Sum(FLD1,subgroupfield)

@Subgroup_fld2_row_total

//Assuming that there are only two categories

//you can simply take a sum of FLD2, which will contain values

//for each category

Sum(FLD2,subgroupfield)

8) Next, you'll create a row percentage similar to the following:

@Subgroup_row_percentage

If

Sum(Fld1,subgroupfield) <> 0

Then

((Sum(Fld1,subgroupfield) - Sum(Fld2,subgroupfield)) / Sum(Fld1,subgroupfield)) * 100

Else

0

9) You'll need to repeat these steps to create summaries at the primary group level and at the Grand Total Level

~Kurt