Share via

How do I create a difference formula in a query?

Anonymous
2010-04-08T15:14:54+00:00

I want to create a column in my query that show the difference between two numbers; without generating the negative numbers by setting up a simple subtracting. The ex. below is what I want for the Difference Column.

                        Planned Lead Time      Actual Delivery          Difference

Part Number 1              15                           10                           5

Part Number 2              20                           20                           0

Part Number 3              30                           35                           5

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Anonymous
2010-04-08T21:38:21+00:00

Hi There,

Here's an expression that should accomplish what you need:

Difference: IIf(([planned]-[actual])>0,([planned]-[actual]),([planned]-[actual])*-1)

HTH,

Kathy

Was this answer helpful?

5 people found this answer helpful.
0 comments No comments

Answer accepted by question author

Anonymous
2010-04-09T00:13:06+00:00

kayte wrote:

> I want to create a column in my query that show the difference between two numbers; without generating the

> negative numbers by setting up a simple subtracting. The ex. below is what I want for the Difference Column.

>

> Planned Lead Time Actual Delivery Difference

> Part Number 1 15 10 5

> Part Number 2 20 20 0

> Part Number 3 30 35 5

Difference: Abs(Planned-Actual)

--

Peter Doering [MVP Access]

Was this answer helpful?

0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Anonymous
    2010-04-09T15:24:30+00:00

    Kathy S - Microsoft Support wrote:

    > Good call Peter. I always forget about the ABS function..

    Hi Kathy, I try to avoid IIF in queries wherever I can. I would even claim

    there is no need for IIF in SQL, and that I can find a faster workaround.

    Prove me wrong ... <g>

    --

    Peter Doering [MVP Access]

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-04-09T01:49:07+00:00

    Good call Peter. I always forget about the ABS function..

    Was this answer helpful?

    0 comments No comments