Sorting complex iif statement queries

  • Thread starter Thread starter SHABA8331
  • Start date Start date
S

SHABA8331

I'M USING NESTED IIF STATEMENTS IN A QUERY BUT CANNOT SORT
THE FIELD. THE ONLY WAY I'VE FOUND IS TO CREATE ANOTHER
QUERY THAT CALLS THE IIF QUERY THEN SORT THE COLUMN. THIS
SLOWS THE DATABASE DOWN - IS THERE ANY OTHER WAY?
 
If necessary, you can repeat the calculated field with the IIF() statements
in the ORDER BY clause of the query.

It would be more efficient to sort on the individual fields if possible.

Even better, could you replace this huge IIF()? Create a small lookup table
with fields:
ValueToMatch - matches the initial values in the IIf().
ValueToShow - the text you wish to display instead.
SortOrder - number indicating the sort order.
Now you can include this lookup table in your query, drop the slow'n'clumsy
IIf() statement, and simply sort on the SortOrder column.

(BTW, see if your keyboard has a CapsLock key so people don't think you are
shouting at them.)
 
Back
Top