Share via

How do I get the minimum from multiple calculated fields

Anonymous
2017-10-12T22:22:49+00:00

I have 5 calculated fields in an Access query and I need to determine the minimum number of all 5 fields.  I'm sure I could do a giant IIF statement but it seems there could be a better way.  I am calculating the difference between production and production levels.  If the person has already hit the highest level, the number should be 0 (zero). I am not a programmer so can anybody help me with this?

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
2017-10-19T21:52:07+00:00

You have confirmed our suspicions.  In a relational database each level should not be represented by a column in a table, but by a row in a related table.  For each row in a promotions table there would therefore be up to five rows in a referencing table of levels whose columns would be a foreign key referencing the primary key of the promotions table, a column to identify the level, whose value could simply be a number within the range 1 to 5, and a third column to quantify the value achieved at that level.  The primary key of the referencing table would be a composite one made up of the first two of these columns.  It is then possible to compute any aggregations over the set of levels reached per promotion by use of the standard SQL aggregation operators like SUM, COUNT, MIN, MAX or AVG.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

12 additional answers

Sort by: Most helpful
  1. Anonymous
    2017-10-17T00:54:22+00:00

    You can have multiple fields showing minimum in each separately.

    SELECT SomeField, Min(AnotherField) AS MinOfAnotherField, Min(NextField) AS MinOfNextField, Min(LastField) AS MinOfLastField

    FROM SomeTable

    GROUP BY SomeField;

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2017-10-13T23:58:12+00:00

    Perfect, happy you solved your issue!

    Ciao

    Ugo

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2017-10-13T15:08:01+00:00

    Thank you but MIN handles only one expression, I have multiple.     

    I found the MinOfList VBA code which works great.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2017-10-12T22:25:08+00:00

    Ciao,

    I'm not sure I got your issue but did you try the MIN function in the expression builder?

    Please let us know.

    Thanks

    Ugo

    Was this answer helpful?

    0 comments No comments