Print Page | Close Window

suppress column based on value of 1 field

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Technical Questions
Forum Discription: Formulas, charting data, Crystal syntax, etc.
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=20277
Printed Date: 26 Apr 2024 at 5:34am


Topic: suppress column based on value of 1 field
Posted By: Gurbs
Subject: suppress column based on value of 1 field
Date 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



Replies:
Posted By: Sastry
Date 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


Posted By: Gurbs
Date 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


Posted By: lockwelle
Date 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


Posted By: Sastry
Date 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


Posted By: Gurbs
Date 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


Posted By: Sastry
Date Posted: 11 Dec 2013 at 6:36pm
Hi Gurbs,

Excellent !

Thanks for sharing this. Smile


-------------
Thanks,
Sastry


Posted By: Gurbs
Date 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



Print Page | Close Window