Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2020 : Technical Questions
Message Icon Topic: suppress column based on value of 1 field Post Reply Post New Topic
Author Message
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Topic: suppress column based on value of 1 field
    Posted: 09 Dec 2013 at 10:15pm
Hi all,

I want to suppress an entire column, based on the value in row 1. If I add the recordnumber it only counts for that specific record, not for everything.

I want to suppress everything, except when the first row contains a certain value.

Thanks in advance.

Kind regards

Gerben
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 09 Dec 2013 at 10:30pm
Hi

Create below formula and place in it in required section .

Whileprintingrecords;
Numbervar x:=X+1;

Now right click on the column (which you want to suppress) go in Format Field--Common--Suppress-- Condition formula editor and give below formula

Whileprintingrecords;
Numbervar x;

If x>1 then true else false


Thanks,
Sastry
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 09 Dec 2013 at 11:13pm
Hi Sastry,

This is just showing everything, no matter the value in the first line. I want to suppress the entire column, based on the value of the first column.

Example:

The data looks like this (this is without headers):
Recordnumber   Service     Amount
2              Wash        10.00
3              Clean       5.00

I only want to show the entire column if the first row contains the words service or amount. This should result in the data showing like:
               Service     Amount
               Wash        10.00
               Clean       5.00

Hope this makes any sense
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4372
Quote lockwelle Replybullet Posted: 10 Dec 2013 at 4:49am
create a formula, I would put in the report header, like:
shared booleanvar showRow := false;
if {table.field} in ['Service','Amount'] then
showRow := true;
"" //hide the formula output.


now in the column detail section, in the suppress x-1 button:

shared booleanvar showRow;
not showRow;

this will suppress the column based on the value in the first row of the data.

HTH
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 10 Dec 2013 at 6:51pm
Hi

There are two ways of doing it, one could be of extracting first row field value through Add Command( Free hand SQL)

Second would be of inserting same report as a sub report in report header section.

If you insert sub report, use shared variables and pass first record information to your main report, based on this information you can suppress the column.


Thanks,
Sastry
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 10 Dec 2013 at 10:03pm
Hi,

I ended up using a different method. I created a formula called 'Suppress saying if {table.field} in ['Service','Amount'] then 1 else 0.

In my suppress formula, I said count({@Suppress}) = 0
IP IP Logged
Sastry
Moderator
Moderator
Avatar

Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
Quote Sastry Replybullet Posted: 11 Dec 2013 at 6:36pm
Hi Gurbs,

Excellent !

Thanks for sharing this. Smile
Thanks,
Sastry
IP IP Logged
Gurbs
Senior Member
Senior Member
Avatar

Joined: 16 Feb 2012
Location: Ireland
Online Status: Offline
Posts: 216
Quote Gurbs Replybullet Posted: 11 Dec 2013 at 9:08pm
Sorry, I see I made a small mistake... it isn't count({@Suppress}) = 0, but sum({@Suppress}) = 0
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.