cancel
Showing results for 
Search instead for 
Did you mean: 

Dynamically color to each column in Cross-tab report

Former Member
0 Kudos

Hello All,

I am a newbie in Crystal report,from last few weeks, i am working on cross tab crystal report.i have a requirement to show color dynamically for each column.i am adding an attachment how i want it. i tried dynamic coloring using object field formula but it is showing red color to all data.i want red color data when in 2nd  cross tab report data is beyond upper or lower limit in first cross tab table. it will be very helpful if somebody will give me any clue on this.... i read so many articles now it seem like impossible for me..:(

i am using visual studio 2010 and sap crystal report version 13.0.0.99 for visual studio 2010.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hey Guys,i don't know whether it is possible or not. you people have experience in sap crystal report.if you think that it is not possible then please let me know. because after getting response only,i can talk to my management that what they are asking its impossible. at-least give response whether its positive or negative.

abhilash_kumar
Active Contributor
0 Kudos

Hi Manish,

This is not impossible to do however it is not the easiest thing to do either.

Would there always be five clients?

If yes, then you should consider creating a manual crosstab. If not for a manual crosstab, it gets very difficult to compare each value in the crosstab with a corresponding number that is not part of the crosstab - in this case the upper and lower limits.

-Abhilash

former_member205840
Active Contributor
0 Kudos

Hi

When you create a cross tab it groups the values according to column and row, now how can we related two cross tab groups and write a condition to change the color ?

It is not possible to achieve this through cross tab, but you can create a standard report in cross tab style i.e. mock cross tab.

Here we can refer / use other values to change the color of values.

Example :

If {Client} = 'Client1' and ({Value} < {LowerLimit} or {Value} > {HigherLimit}) Then CrRed Else CrNoColor

-Sastry

Former Member
0 Kudos

hi Abhilash,

my cross tab has also dynamic column which can be increased and decreased.with  my second cross tab my first cross tab will also do same behavior. i cannot fix column numbers as  requirement. if any other way is there then please let me know...

Answers (1)

Answers (1)

former_member260594
Active Contributor
0 Kudos

Hello Manish,

I have attached a sample report that does this. You will need to remove the .txt extension from the attached file to open it as an .rpt file.

Please right click on one of the value fields of the first cross tab in the report > Format Field > Common > Suppress if Duplicated conditional formula.

The nested formula is as follows;

numbervar array l;
numbervar array u;
numbervar x:=CurrentColumnIndex;
if GridRowColumnValue ('@limit') = 'lower limit' then
(redim preserve l[x];
l[x]:= tonumber(CurrentFieldValue))
else if GridRowColumnValue ('@limit') = 'upper limit' then
(redim preserve u[x];
u[x]:= tonumber(CurrentFieldValue));

false

So it assigns each lower and upper limit value for each client (in the sample it is country) to an array using the cross tabs column index to index the array and it ends in False as we don't actually want it to suppress if duplicated. This nested formula is just used to generate the arrays of upper and lower values.

In the second cross tab if you again right click on one of the value fields > Format Field > Font > Color you will see the following conditional formula;

numbervar array l;

numbervar array u;

numbervar x;

if not(tonumber(CurrentFieldValue) in l[CurrentColumnIndex] to u[CurrentColumnIndex]) then

crred

else

crblack

So this compaes the current field value to range generated by the 2 arrays and assigns a color based on whether or not it is in the range.

Regards,
Graham

Former Member
0 Kudos

thanks for reply Graham,

but i am not able to open your rpt file. i converted it from .txt to .rpt. but when i am opening it using visual studio it is give error. here i am attaching the screen shot of this error. are you using different version of sap crystal report?

former_member183750
Active Contributor
0 Kudos

Work fine for me:

The file unziped to sample_crosstab_relation.rpt.txt. All I had to do is remove the the .txt.

it also opens just fine in the stand-alone CR designer...

- Ludek

Former Member
0 Kudos

hii Graham,

i tried your solution but i am getting array index error in my 2nd cross tab. its not a simple number value. it has some characters also in cell like n/a or null according to selection which client want to choose.

here i am pasting the screen shot of the error as well as my crosstab report screen shot. if any one know the solution then please help me. i was trying from last more than 7 days still not getting any idea to solve it. waiting for response..