Balance Comparison Query

G

Guest

I need some help with this query/report. My query does a comparison between
records in current month and records in previous month. It basically takes
active account numbers and balances for current month and compares it to
active accounts and balances from previous month. I am having some
difficulty when I try to subtract on an account which only exist in one month
(either previous or current.)

I use this if statement to do my calculation:

Balance Difference = iif(CurrentMth.AccountNr = “â€,
PreviousMth.Balance,iff(PreviousMth.AccountNr= “â€,
CurrentMth.Balance,CurrentMth.Balance – PreviousMth.Balance))

This works great if the account is active both current month and previous
month, but where the account only exist in one month I get a blank result.

I want the query to return the difference even if the account only exist in
one month.

Thanks for all your help!

Nats
 
G

Guest

Try something like:
Balance Difference = IIf(IsNull(CurrentMth.AccountNr),
PreviousMth.Balance,IIf(IsNull(PreviousMth.AccountNr),
CurrentMth.Balance,CurrentMth.Balance – PreviousMth.Balance))

Keep in mind that No Value and Null are not the same as "". You may also
want to convert Nulls to zero or some other values with
Nz([PossiblyNullField],0)
 
G

Guest

Thanks a bunch! That worked great.

Duane Hookom said:
Try something like:
Balance Difference = IIf(IsNull(CurrentMth.AccountNr),
PreviousMth.Balance,IIf(IsNull(PreviousMth.AccountNr),
CurrentMth.Balance,CurrentMth.Balance – PreviousMth.Balance))

Keep in mind that No Value and Null are not the same as "". You may also
want to convert Nulls to zero or some other values with
Nz([PossiblyNullField],0)

--
Duane Hookom
Microsoft Access MVP


Natalie said:
I need some help with this query/report. My query does a comparison between
records in current month and records in previous month. It basically takes
active account numbers and balances for current month and compares it to
active accounts and balances from previous month. I am having some
difficulty when I try to subtract on an account which only exist in one month
(either previous or current.)

I use this if statement to do my calculation:

Balance Difference = iif(CurrentMth.AccountNr = “â€,
PreviousMth.Balance,iff(PreviousMth.AccountNr= “â€,
CurrentMth.Balance,CurrentMth.Balance – PreviousMth.Balance))

This works great if the account is active both current month and previous
month, but where the account only exist in one month I get a blank result.

I want the query to return the difference even if the account only exist in
one month.

Thanks for all your help!

Nats
 

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