cancel
Showing results for 
Search instead for 
Did you mean: 

Cross-tab row formatting inconsistent

Former Member
0 Kudos

Hi

I have created a Crystal Report XI cross-tab with 3 columns.

I have built a background formula into the row header and data fields to provide alternater row background shading like the below.

This works fine when there is an even number of rows, but fails when there is an odd number of rows

In the formulas I use whileprintingrecords, and I am struggling to work out how to correct this behaviour - or even how whileprintingrecords increments the variables in these examples of even and odd rows.

My background formulas are as follows:

Row headers (e.g. July, Aug etc)

<code>whileprintingrecords;numbervar f1;f1 := iif(f1=1,0,1);iif(f1=0,color(197,217,241),color(255,255,255));</code>

'Usage' row data

<code>whileprintingrecords;numbervar f2;f2 := iif(f2=1,0,1);iif(f2=1,color(197,217,241),color(255,255,255));</code>

'%' row data

<code>whileprintingrecords;numbervar f3;f3 := iif(f3=1,0,1);iif(f3=1,color(197,217,241),color(255,255,255));</code>

'Value' row data

<code>whileprintingrecords;numbervar f4;f4 := iif(f4=1,0,1);iif(f4=1,color(197,217,241),color(255,255,255));</code>

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Thanks for your suggestions everyone.

I was able to control the formatting by updating a formula to include a running total I have created which I could use to identify the number of rows that would be output

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi Bob,

What is the reason for this being a cross tab object? Can it not just be a dimensions and three running total or formula objects?

former_member260594
Active Contributor
0 Kudos

Hello Bob,

Try resetting the 'data' variables in the headers using a nested reset formula. For instance, right click on the Usage header > format field and enter in the following conditional suppression formula;

numbervar f2:=0;

false

Regards,

Graham

abhilash_kumar
Active Contributor
0 Kudos

Hi Bob,

Is this a 'Crosstab' object?

I'm asking this because you really do not need to put these formulas in each 'column' of the crosstab.

When you select the summary fields in the crosstab, it selects all the columns.

Is this a manual crosstab?

- Abhilash

Follow us on Twitter

Got Enhancement ideas? Try the SAP Idea Place

Share Your Knowledge in SCN Topic Spaces

jyothirmayee_s
Active Contributor
0 Kudos

Hi,

Can u try using the same formula as row for the columns too

Like f2,f3,f4=0 ..try and let me know if it don't work

Thanks,

Jothi

Former Member
0 Kudos

Thanks for the response Jothi.

It has the opposite effect.

When I applied the formula you suggested I find background formatting is OK where there is an odd number of rows, but fails in the same way when there is an even number of rows,

Is there a way to establish how many rows there would be in the cross-tab?

If it is an even number I can apply the background formula as I originally designed.

If it is an odd number I can apply the background formula as you had suggested.

jyothirmayee_s
Active Contributor
0 Kudos

Hi ,

If it is a crosstab then can you try below forula for coloring and also go thru the link.

http://www.tek-tips.com/viewthread.cfm?qid=1618459

Global NumberVar CountRow := CountRow + 1;

If CountRow Mod DistinctCount ({RowGroup.Field}) = 0 or

    (CountRow Mod DistinctCount ({RowGroup.Field})) Mod 2 <> 0 Then

    CrNoColor   

Else

    Color(238,238,238)

OR

Right-click on one of the values in the row label, select Format Field, click the conditional formatting button to the right of Background and enter the following formula:

IF Remainder (CurrentRowIndex, 2) <> 0

THEN Color (200, 200, 200)

ELSE crNoColor

Thanks,

Jothi