Why does abs work for negative values?

M

mike

Hi. I have a query that seems to work but I don't
understand how I'm getting the right answer every time. I
have a formula that calculates sales orders between two
dates. I'm using the Abs function and I don't understand
how I'm able to get away with not turning all of my sales
returns (negative values) into positives by mistake. It
works fine. Anyone know why? Thanks!!

DollarsShipped: Nz(Sum(Abs(([InvoiceDate] Between [Forms]!
[Dashboard]![FirstDayOfTrendPeriod] And [Forms]!
[Dashboard]![LastDayOfTrendPeriod]))*[DollarsShipped]),0)
 
A

Anne Nolan

The ABS part of your expression can be simplified for readability as
follows:
(Abs([InvoiceDate] Between [FirstDayOfTrendPeriod] And
[LastDayOfTrendPeriod])

The part within the () is an expression that returns True or False,
depending on whether your InvoiceDate is within the given range. The ABS is
just converting the "True" values to a positive 1 (True = -1, in Access).
It's not operating on your "Dollars Shipped" value at all.

Anne
 
M

mike

Anne, That was very clear. Thanks!
-----Original Message-----
The ABS part of your expression can be simplified for readability as
follows:
(Abs([InvoiceDate] Between [FirstDayOfTrendPeriod] And
[LastDayOfTrendPeriod])

The part within the () is an expression that returns True or False,
depending on whether your InvoiceDate is within the given range. The ABS is
just converting the "True" values to a positive 1 (True = -1, in Access).
It's not operating on your "Dollars Shipped" value at all.

Anne

Hi. I have a query that seems to work but I don't
understand how I'm getting the right answer every time. I
have a formula that calculates sales orders between two
dates. I'm using the Abs function and I don't understand
how I'm able to get away with not turning all of my sales
returns (negative values) into positives by mistake. It
works fine. Anyone know why? Thanks!!

DollarsShipped: Nz(Sum(Abs(([InvoiceDate] Between [Forms]!
[Dashboard]![FirstDayOfTrendPeriod] And [Forms]!
[Dashboard]![LastDayOfTrendPeriod]))*
[DollarsShipped]),0)


.
 

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