Adding formula to union query

asmith601

New Member
Joined
Dec 5, 2017
Messages
20
Office Version
  1. 2019
Platform
  1. Windows
Hi everyone. I am almost done with my project, but I need help with something. Can someone help with getting the following to work?

SELECT ID as Eval, "Preparation and Punctuality" AS Criteria, I_Q1 AS Grade, =IF([I_Q1]=1,"F","ERROR") AS LETTER_GRADE
FROM issues
UNION SELECT ID, "Subject Knowledge",I_Q2
FROM issues
UNION SELECT ID, "Available to Meet Student Needs",I_Q3
FROM issues;

I have done union queries numerous times before, however I have never tried to incorporate an if statement into one. I would like a formula that can translate number values into letters (1=F, 2=D, 3=C....) into a column. is this possible? Any help is appreciated.

Thanks in advance!
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
A union query MUST have the same number of columns in each part. So your query looks like it won't work (first part has 3 columns, and the other two have only two columns.

At minimum you'd have provide some third values in the last two parts (an empty string, a dummy value such as "n/a", or a Null).
 
Upvote 0
Thank xenou. I see now that I do not have the 3rd column on the other parts now. Thanks for bringing that up. The last item appeared to be using "IF" instead of "IIF". Formula seems to work now. Thanks!
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,824
Messages
6,181,186
Members
453,020
Latest member
Mohamed Magdi Tawfiq Emam

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