indicator

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have the following columns in my query empid, courseA, datecompA, courseB,
datecompB, courseC, datecompC. What I need is an extra column that will have
an indicator Yes if any of the 2 dates(i.e., datecompA, datecompB, datecompC)
have dates, blank if all 3 dates have dates and No if only of the dates has
a date.
 
Not sure what the third criteria is, but you can use something like

Abs(IsNull(datecompA) + IsNull(datecompB) + IsNull(datecompC))

The IsNull will return -1 (True) Or 0 (False) if the date is empty.
The Abs will return the Absolute number
So, adding all the -1 will add up to the number of date field that are filled

IIf(Abs(IsNull(datecompA) + IsNull(datecompB) + IsNull(datecompC)) = 2
,"Yes",IIf(Abs(IsNull(datecompA) + IsNull(datecompB) + IsNull(datecompC)) = 3
, Null , "No"))
 
Thanks alot that worked perfect...

Ofer Cohen said:
Not sure what the third criteria is, but you can use something like

Abs(IsNull(datecompA) + IsNull(datecompB) + IsNull(datecompC))

The IsNull will return -1 (True) Or 0 (False) if the date is empty.
The Abs will return the Absolute number
So, adding all the -1 will add up to the number of date field that are filled

IIf(Abs(IsNull(datecompA) + IsNull(datecompB) + IsNull(datecompC)) = 2
,"Yes",IIf(Abs(IsNull(datecompA) + IsNull(datecompB) + IsNull(datecompC)) = 3
, Null , "No"))
 

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

Similar Threads

New column in query 2
HELP PLZ... (complicated query) 2
#error - Blank 3
Excel Help with dates 2
Query to select individual records 4
Need Help With Make Table Query 2
Excel Sumproduct 0
Non-Equal values in Queries 5

Back
Top