Search code examples
crystal-reportscrystal-reports-xi

Crystal XI - How to find difference between 2 customer prices for same item


I have a table that lists customer number, item number and item price (based on customer number). What I'd like to do in Crystal is show the difference in item price for each customer/item number as compared against the item price for a specific customer ('Jeremy'). For example:

Customer name = Jeremy
price for item 1 = $20
price for item 2 = $30
price for item 3 = $40

Customer name = Mike
price for item 1 = $10
price for item 2 = $25
price for item 3 = $30

For all customers and all items show: Current Customer's name, Current item name, and Difference between Jeremy's item price and Current Customer's item price. i.e.
Mike, item 1, $10 (difference) Mike, item 2, $5 (difference) Mike, item 3, $10 (difference)

I'm getting hung up on how to show the price difference between the current customer's item price compared against Jeremy's item price for every item (and then repeat the same step for every customer as compared against Jeremy).

Any help would be appreciated.


Solution

  • What I suggest before read further comment. Try to get this value from stored procedure or say when you get the data , add one column of compare value. Which is faster solution and nothing to be worry in crystal report side.

    I had done this type of issue in db side, not crystal report side.

    Still you want to in crystal report, then you can achieve by formula in variable.

    You have to store the value in each variable in detail section and at the time of result , just compare.

    or

    You can do by the cross-tab report and at last you just give add formulated variable which gives the result, but this is tedious job.