Solved

another query question

Posted on 2016-10-28
7
53 Views
Last Modified: 2016-10-28
Hi Experts,
I have another query question.  I have a query below:
Cal/Dist: IIf([RMLOCATION] In ("Z (Dist 6)","H (Dist 6)","District 6x","District 6"),"District 6",IIf([RMLOCATION] In ("V (Dist 2)","District 2"),"District 2",IIf([RMLOCATION] In ("W (Dist 3)","G (Dist 3)","District 3"),"District 3",IIf([RMLOCATION] In ("X (Dist 4)","District 4"),"District 4",IIf([RMLOCATION] In ("Y (Dist 5)","District 5","Calendar87"),"District 5",IIf(Left([RMLOCATION],1)="C",[RMLOCATION]))))))

my question is how do I exclude the "calendar 87" on the IIf(Left([RMLOCATION],1)="C",[RMLOCATION]) since "Calendar 87 is included in the District 5 and I have to removed from the part of IIf(Left([RMLOCATION],1)="C",[RMLOCATION]).

Thanks,
0
Comment
Question by:urjudo
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41864318
it will be best if you create a table with all the combination that you want.
the query will then be very simple using a join to the combination table.
0
 

Author Comment

by:urjudo
ID: 41864339
all calendars are in one table
0
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 41864349
<all calendars are in one table > what table? is there a relationship to this table and the other table in the query?

how about the other parts of your IIF() statements?
0
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 

Author Comment

by:urjudo
ID: 41864384
SELECT IIf([RMLOCATION] In ("Z (Dist 6)","H (Dist 6)","District 6x","District 6"),"District 6",IIf([RMLOCATION] In ("V (Dist 2)","District 2"),"District 2",IIf([RMLOCATION] In ("W (Dist 3)","G (Dist 3)","District 3"),"District 3",IIf([RMLOCATION] In ("X (Dist 4)","District 4"),"District 4",IIf([RMLOCATION] In ("Y (Dist 5)","District 5","Calendar87"),"District 5",IIf(Left([RMLOCATION],1)="C",[RMLOCATION])))))) AS [Cal/Dist]
FROM tblCourtRoom
GROUP BY IIf([RMLOCATION] In ("Z (Dist 6)","H (Dist 6)","District 6x","District 6"),"District 6",IIf([RMLOCATION] In ("V (Dist 2)","District 2"),"District 2",IIf([RMLOCATION] In ("W (Dist 3)","G (Dist 3)","District 3"),"District 3",IIf([RMLOCATION] In ("X (Dist 4)","District 4"),"District 4",IIf([RMLOCATION] In ("Y (Dist 5)","District 5","Calendar87"),"District 5",IIf(Left([RMLOCATION],1)="C",[RMLOCATION])))))), tblCourtRoom.STATUS
HAVING (((tblCourtRoom.STATUS)="Active"));
0
 
LVL 36

Accepted Solution

by:
PatHartman earned 500 total points
ID: 41864390
how do I exclude the "calendar 87" on the IIf(Left([RMLOCATION],1)="C",[RMLOCATION])

The answer is - You Don't.  I believe in another post, I explained to you that the IIf() exits as soon as something falls into the final true path.

Your code isn't working because you have a typo.  There is no space between Calendar and 87 in the IIf()
0
 

Author Closing Comment

by:urjudo
ID: 41864398
Thanks!!! I did not see there is no space.  sorry
0
 
LVL 36

Expert Comment

by:PatHartman
ID: 41864411
PS - I agree with Rey.  This type of a conversion is better done with a cross-reference table.  I'm sure you are going to end up with more than one query that includes this logic and the table solves the entire problem in a consistent way.  You just change the table to move/add groupings.  The default is handled in the query.

Select ..., IIf(IsNull(tblGroup.GroupName), tblCourtRoom.RMLOCATION, GroupName) As Group
From tblCourtRoom Left Join tblGroup On tblCourtroom.RMLOCATION = tblGroup.RMLOCATION
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question