V9 PO extended cost calculation help with costpercode

I’m trying to write what I thought was a simple query showing purchase order lines with extended price. We price in each and we price in per thousand (PODetail.CostperCode). I tried this several ways but keep getting an error. Basically, I am trying to say, "If the cost per is 1,000 (M in the table), then divide the orderqty by 1000 before multiplying times unit price. Otherwise, it’s just our quantity times the unit cost. (In V10, this value is in the table, but not in V9 as far as I can tell)


Create calculated field for CostPerCode. as below
if PODetail.CostPerCode = “M” then 1000 else if PODetail.CostPerCode = “C” then 100 else 1.
Ext_Cost - (PODetail.UnitCost / CostPerCode) * PODetail.OrderQty

Thank you very much Arul. Your approach made a lot more sense.