Why does abs work for negative values?

  • Thread starter Thread starter mike
  • Start date Start date
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)
 
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
 
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)


.
 
Back
Top