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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formula for field that contains or ends with DP or AD

Status
Not open for further replies.

crystalpro

Technical User
Jan 22, 2002
95
US
I need to be able to get invoice amounts for invoices that have an invoice number that ends with "DP" or "AD". The invoice number may be 4,5, or 6 characters followed by DP or AD. If the invoice ends in DP, I want crystal to multiply an amount field by -1. If the invoice ends in AD, then I want crystal to just use the amount field.

The formula looks something like:
If {JrnlHdr.Reference} ??????(ends with DP) then
{JrnlRow.UnitCost} * -1
else
if {JrnlHdr.Reference} ??????(ends with AD) then
{JrnlRow.UnitCost}
else 0
 
Trim the string using the right command....

If Right({JrnlHdr.Reference}, 2) = 'DP' then
{JrnlRow.UnitCost} * -1
else
if Right({JrnlHdr.Reference}, 2) = 'AD' then
{JrnlRow.UnitCost}
else 0

That should do it.
 
Try:

If right(trim({JrnlHdr.Reference}),2) = "DP" then
{JrnlRow.UnitCost} * -1
else
if right(TRIM({JrnlHdr.Reference}),2) = "AD" then
{JrnlRow.UnitCost}
else 0

-K
 

If right(trim({JrnlHdr.Reference}),2) in ["DP","AD"] then
{JrnlRow.UnitCost} * -1 else 0


Reebo
Scotland (Sunny with a Smile)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top