Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Need help with Crystal XI Conditional Text formula 1

Status
Not open for further replies.

jpeters01

Technical User
Dec 5, 2007
109
US
Hi, I need to compare a datetime field with a date range and then display conditional text. For example if {Table.Delv_Date} is in Date Range 12/14/2008-12/27/2008 then I need to display PP1_2009. This is my formula where the text that needs to display is in quotes but this is not working. From other posts, I think I might need to create a variable, but do not know how to incorporate it into this formula.

if DATE ({up_rpt_PickTicket.DELV_DATE}) in Date(12/14/2008) to Date(12/27/2008)then "PP1_2009" else
if DATE ({up_rpt_PickTicket.DELV_DATE}) in Date(12/28/2008) to Date(1/10/2009)then "PP2_2009" else
if DATE ({up_rpt_PickTicket.DELV_DATE}) in Date(1/11/2009) to Date(1/24/2009)then "PP3_2009" else

Thank you
 
I think you've basically got it, except in CR the "in" operator requires the range values to be in square brackets:

if DATE ({up_rpt_PickTicket.DELV_DATE}) in [Date(12/14/2008) to Date(12/27/2008)] then "PP1_2009"

elseif DATE ({up_rpt_PickTicket.DELV_DATE}) in [Date(12/28/2008) to Date(1/10/2009)]then "PP2_2009"

elseif DATE ({up_rpt_PickTicket.DELV_DATE}) in [Date(1/11/2009) to Date(1/24/2009)] then "PP3_2009" else

 
Thanks for your reply Brian, I tried that but the text does not display.
 
Hi,
The range test is not the same as the IN operator so the brackets are not required but, unless you have a quoted string, you need to reformat the dates..

For your formula try giving a default text is no range is met:
Code:
if DATE ({up_rpt_PickTicket.DELV_DATE}) in 
Date(2008,12,14) to Date(2008,12,27)
then "PP1_2009" 
else
if DATE ({up_rpt_PickTicket.DELV_DATE}) in 
Date(2008,12,28) to Date(2009,01,10)
then "PP2_2009" 
else
if DATE ({up_rpt_PickTicket.DELV_DATE}) in 
Date(2009,01,11) to Date(2009,01,24)
then "PP3_2009" 
else
"Not in target ranges"

OR

Code:
if DATE ({up_rpt_PickTicket.DELV_DATE}) 
in Date("12/14/2008") to Date("12/27/2008")
then "PP1_2009" 
else
if DATE ({up_rpt_PickTicket.DELV_DATE}) in 
Date("12/28/2008") to Date("1/10/2009")
then 
"PP2_2009" 
else
if DATE ({up_rpt_PickTicket.DELV_DATE}) in 
Date("1/11/2009") to Date("1/24/2009")
then "PP3_2009" 
else
"Not in target ranges"





By 'not working' do you mean nothing displays or there is an error message?







[profile]

To Paraphrase:"The Help you get is proportional to the Help you give.."
 
Sorry I should have said "nothing displays." However Turkbear's solution of using quotes, ("12/14/2008") worked :) Thank you Turkbear!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top