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

Create a formula requiring the contents of a specific field's value

Status
Not open for further replies.

dianne2n

MIS
Joined
Jan 31, 2003
Messages
13
Location
US

I have a table which resembles the following:


-------------------
ID | Cost
-------------------
100 | 23.50
-------------------
200 | 12.00
-------------------
300 | 4.25
-------------------

I'm trying to create a formula like:
xxx = ({qty} * [value in the cost field where ID=200])

can you give me a hand?
Thanks

 
One option is to use a subreport (placed in the Main Report Header) to load an SHARED string array variable with all these values. Then, in the main report, any formula can declare the SHARED variable to get access to its value, loop through the array and grab the correct entry.

Cheers,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
I don't see the qty field, but this should get you close as a formula:

If {table.id} = 200 then
(table.qty} * {table.cost}

If you only want to display data for those that are of the ID 200, then go into the record selection formula (Report->Edit Selection Formula->Record) and place:

{table.id} = 200

This will limit the rows to only ID 200, so the IF check wouldn't be required.

-k
 
Try:

If {ID} = "200" then {qty}*{cost} else 0 //assumes ID is a string; if not, remove quotes

If you place this in details, you can then perform summaries on the field.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top