Print Page | Close Window

conditional section

Printed From: Crystal Reports Book
Category: Crystal Reports 9 through 2020
Forum Name: Report Design
Forum Discription: The best way to design a report and problems you have encountered
URL: http://www.crystalreportsbook.com/forum/forum_posts.asp?TID=7621
Printed Date: 05 May 2024 at 6:57am


Topic: conditional section
Posted By: kirandb
Subject: conditional section
Date Posted: 08 Sep 2009 at 9:15am
i am using crystal 2008. I have to use conditional section as
 
if col3 = 50001 then
display columns 1,2,6,7,8
else
display columns 1,4,6,7,8
 
please help me in implementing this.
i could add a details section from section expert. so now my report has details a and details b but i dont know how to implement the above condition.
 
Thanks,
Kiran


-------------
share your knowledge



Replies:
Posted By: DBlank
Date Posted: 08 Sep 2009 at 10:51am
I assume you have columns 1,2,6,7,8 on detail section a and columns 1,4,6,7,8 on detail section b.
I also assume that column3 is really a field that is on each row.
In the section expert select detail section A.
Click on the formula button next to "Suppress no drill down" and add your suppression condition here...
{table.col3field}<>50001
//if it is text and not numeric make it <>"50001"
Now select section detail b and do the same thing but use the formul...
{table.col3field}=50001


Posted By: kirandb
Date Posted: 08 Sep 2009 at 11:27am
Thanks. It works.
My report displays background color on alternate rows.
What I did was to add following code
if RecordNumber mod 2 = 0 then crSilver else crNoColor
 
in both the Details a, Details b section.
It seems to work but is it the right way to do it.
 
Thanks,
Kiran
 


-------------
share your knowledge


Posted By: DBlank
Date Posted: 08 Sep 2009 at 11:36am
Assuming you do not have conditional suppression ofa an entire row (both a and B) then your background should work.
 
If you do suppress an entire row /record # then you would need to add a counter / Running Total to use for the "x mod 2=0"
 
FYI - I assume you are just flipping "column 2 and 4" on these rows. You can also do this by placing these fields on top of each other on the same detail and conditionally suppress each field the same way you did the entire row... or you can make one formula field that would "flip" between the fields and display it instead...This formula fierld can also be used for sums/counts....
if {table.col3field}=50001 then {table.col2field} else {table.col4field}


Posted By: kirandb
Date Posted: 08 Sep 2009 at 11:41am
Thanks, thats good information but is flipping just one column field is faster than the entire row ? do you think that the performance gets affected this way ?

-------------
share your knowledge


Posted By: DBlank
Date Posted: 08 Sep 2009 at 11:44am
I am not an expert on that but my guess in this instance is that using one formula to flip would be better performance than conditiaonl suppression of a or b.


Posted By: kirandb
Date Posted: 08 Sep 2009 at 12:10pm
Thanks for the reply.
Any idea on how to divide my columns by a number.
I want to divide the data coming in columns 6,7 by 1000.
How do i implement it ?
 
Thanks again.
Kiran


-------------
share your knowledge


Posted By: DBlank
Date Posted: 08 Sep 2009 at 12:28pm

Assuming you mean each column individually then create 2 formula fields.

For column 6: {table.column6_field}/1000
For column 7: {table.column7_field}/1000
 
if you wanted the sum divided then:
({table.column6_field} +{table.column7_field})/1000
 


Posted By: kirandb
Date Posted: 08 Sep 2009 at 2:40pm
thanks.got it to work.
I am trying to display my header for col 5 as 'RIGHT({?period},2)' & ' Balance' and col 6 as ToNumber(RIGHT({?period},2))-1' & ' Balance' .
 
I am getting col5 as say 08 Balance and col 6 as 7.00 Balance.
I want col 5 as 07 Balance.
 
I could'nt figure out how to do this. I am doing the above in a formula.
Thanks,
Kiran


-------------
share your knowledge


Posted By: DBlank
Date Posted: 08 Sep 2009 at 2:42pm

'0' + totext(ToNumber(RIGHT({?period},1))-1,0) + ' Balance' 



Posted By: DBlank
Date Posted: 08 Sep 2009 at 2:51pm
Better one to handle in case you run into items that are 2 characters (e.g. 12 instead of 02):
 
totext(ToNumber(RIGHT({?period},2))-1,'00',0) + ' Balance'


Posted By: kirandb
Date Posted: 09 Sep 2009 at 5:53am

Thanks. It works great. HOw do i use a formula within a formula. Say my formula "Prior" gives me previous year,previous quater based on the user parameters and if i want to use this formula to populate my headers which says uses a formula

"Col6" = "Prior" + 'Balance'
 
Any suggestions.
 


-------------
share your knowledge


Posted By: DBlank
Date Posted: 09 Sep 2009 at 7:02am
I am not sure what youa re asking here...Do you just want a text string as a label in a header?


Posted By: kirandb
Date Posted: 09 Sep 2009 at 7:05am

I have a formula which gives me say previous year. Now I want to use this formula within another formula which gives me my header string. So I want to know how to implement a formula within a formula.



-------------
share your knowledge


Posted By: DBlank
Date Posted: 09 Sep 2009 at 7:13am
It all depends on what the first formula is doing and what data type it is.
If prior is a string/text:
"Col6 = " + mailto:%7b@prior - {@prior}  + " Balance"
if prior is numeric:
"Col6 = " + totext( mailto:%7b@prior%7d - {@prior} ,0,"") + " Balance"
would give you a string of "Col6 = 2006 Balance"
 
You can also just make a text and drag and drop fields into it including formula fields.
 


Posted By: kirandb
Date Posted: 09 Sep 2009 at 7:36am
Great. I have a report header to display the date time. the formula i used is :
'Report As of ' + MonthName (Month(CurrentDate)) + ' ' + ToText(Day(CurrentDate),'00',0) + ', ' + Totext(Year (CurrentDate),'0000',0) + ' at ' + ToText(TimeValue (CurrentDateTime))
 
this gives me the data as say : Report as of September 09, 2009 at 9:23:45AM.
How do i eliminate the seconds from the above formula and alos add leading zero for hour and seconds if they are single digit.


-------------
share your knowledge


Posted By: DBlank
Date Posted: 09 Sep 2009 at 8:04am
'Report As of ' + totext(currentdatetime,"MMMM d, yyyy 'at' h:mm:ss tt")
 



Print Page | Close Window