Pivot Table - Using If Then logic

B

blkane

Can you use If Then logic in a calculated field?

I have table of data that is downloaded from an external source. The amount
field is all positive numbers. The adjacent field indicates if the amount
represents a debit or credit value.

I would like to set up a calculated field that to sum the amount field but I
need to have the debit and credits sum to a net number and not a straight sum.

Any thoughts on this? I'm trying to avoid manipulating the entire table to
change the sign on the credit values.

thanks
 
J

Jim Thomlinson

You can not use if then logic in a pivot table. You need to add the logic to
your source data.
 
M

Mike H.

If using VBA, I would replace the amount column with the new "adjusted" amount:

let's say Col I has the Amount and Col J has "Dr" or "Cr"

code:
x=1
Do while true
if cells(x,1).value=empty then exit do 'something to find last row of
data, may
'have to adjust
let Amt=cells(x,9).value
if cells(x,10).value="Dr" then
'do nothing, it is positive!
else
let cells(x,9).value=-1*amt
end if
x=x+1
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top