Field "AS" plus Criteria restriction

mzza

Board Regular
Joined
Nov 8, 2006
Messages
55
Hi,

I am trying to write a query which will select only records from a table where "USER_ID" = "21", but I want the results of this query to display "Birmingham" instead of "21". Is there a way to do this (without a lookup table)? I have tried the following:

Field:USER_ID: "Birmingham"
Table:tbl_Sales
Total:Group By
Sort:
Show:Y
Criteria:"21"

<tbody>
</tbody>


... but it returns no data (presumably because it is evaluating for "21" AFTER applying the AS clause to show all USER_IDs as "Birmingham" (??)

I'm probably doing something really noobish here... :confused:
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
I would recommend NOT using the same name as your Table Field Name as your Calculated Field Name.
So, I would create a calculated field like this:
Code:
UserID: IIF([USER_ID]=21,"Birmingham",[USER_ID])
and then putting "Birmingham" in the Criteria for this field.

Note that if the USER_ID is numeric, you should NOT put quotes around the 21. Only do that if it is a Text/String field.
 
Upvote 0

Forum statistics

Threads
1,221,707
Messages
6,161,416
Members
451,705
Latest member
Priti_190

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top