Solved

# Calculated column cannot be saved without a valid expression in the Expression property

Posted on 2013-10-22
1,834 Views
I am trying to create a table that contains a numerator and denominator for each patient in a population for each of 22 health measures.  My goal is to know, for a certain population, what percentage of all of the eligible patients had that measure done (flu shot, pneumo shot, BP reading, etc.)

My query looks at the data, figures out whether the patient is eligible for that measure, and if so, assigns the number 1 as the denominator.  If the patient had that measure done, the numerator is 1, and if not, it is zero.  For example, patient X had a flu shot during 2013.  The criteria is that the patient is over 18 years old and did not refuse the vaccination.  If they meet these conditions, the denominator field is calculated as 1.  If they had the shot, the numerator field is calculated as 1.

I know that in Access parlance it's better not to store a calculated field in a table, but I need to report on all of these 1's and 0's for 22 different measures, by patient, by attributed physician, and the like.

Is there a way to store these values in a table?  Because when I try to change the query type from "select" to "make table", I get the error described in the title of this post.

Any help would be appreciated.

T_Van
0
Question by:T_Van
• 7
• 6

LVL 74

Expert Comment

ID: 39591854
Then what is the exact expression you are entering?
0

Author Comment

ID: 39591868
I'll give you a couple of examples for the flu shot one:

For Flu Denominator:  Flu Denominator: IIf([Fluvax Date]<DateSerial(2012,10,1) Or [Fluvax Date]>DateSerial(2013,3,31) Or [Fluvax Done?]="N-P" Or [Fluvax Done?]="N-S" Or [Fluvax Done?]="N-M",0,1)

For Flu Numerator:  Flu Numerator: IIf([Flu Denominator]=0,0,IIf([Fluvax Done?]="Y",1,0))

These expressions check a patient ID number, a value, and a date field.  That is only one measure (flu), there are about 10 more in my query, so each measure has a numerator and denominator field in the query, that have different expressions based on the guidelines for inclusion.
0

LVL 74

Expert Comment

ID: 39591877
sb something roughly like this:

IIf( IsOver18=True And DidNotRefuse=True,"Gets the shot","Does not get the shot")

But without knowledge of your Fields, calculations, datatypes, expressions, ...etc
...it is difficult to say what the exact issue and solution should be...
0

LVL 74

Expert Comment

ID: 39591900
Then First, *before worrying about storing this value*, ...
You need to make sure that each segment of your expression returns the correct value and the expressing is syntactically correct.

Flu Denominator: IIf([Fluvax Date]<DateSerial(2012,10,1) Or [Fluvax Date]>DateSerial(2013,3,31) Or [Fluvax Done?]="N-P" Or [Fluvax Done?]="N-S" Or [Fluvax Done?]="N-M",0,1)

For "expressions" this complex, I would rather use a function...

But in any event, ...in your expression above, ...if "Any" of those expressions is True, then it will return 0...
is this what you wanted?

Perhaps I am not seeing something simple, you lets see what other experts may post...

JeffCoachman
0

Author Comment

ID: 39591910
Jeff,

That part is already done.  The expressions themselves are correct, and I tested them all manually as well.  The problem isn't with the expressions - it's that I need a final table, that has the member ID and the numerator and denominator for every patient for every measure.  Normally, I would just make the query a "Make Table" query, but when I do, it gives me the "Calculated column cannot be saved without a valid expression in the Expression property" error.

Here is what I've tried in the interim:  creating a macro that runs the query, exports the data to Excel, and then imports it back as its own table.  There are some bugs in this (I have to delete the table or it will double the records), but for the most part, it works.

Thanks for your help on this!

T_Van
0

LVL 74

Expert Comment

ID: 39591925
Here is what I would do.

Put each of those expressions in their own filed so you can *see* them all.
Are they all correct and valid?
If not, then why bother combining them into a huge expression?
Make sense...?
0

LVL 74

Expert Comment

ID: 39592084
< Normally, I would just make the query a "Make Table" query, but when I do, it gives me the "Calculated column cannot be saved without a valid expression in the Expression property" error.>

Again, ...please post this expression... (or post the entire SQL)
0

Author Comment

ID: 39592124
There is more than one expression - there are 16 different expressions in the query (2 each, one denom, one num) for each of 8 different health measures.

I'll send you the SQL for the entire query:

SELECT [01 - Beneficiary Demographics].HIC, [01 - Beneficiary Demographics].Age, [01 - Beneficiary Demographics].GENDER, IIf([Fluvax Date]<DateSerial(2012,10,1) Or [Fluvax Date]>DateSerial(2013,3,31) Or [Fluvax Done?]="N-P" Or [Fluvax Done?]="N-S" Or [Fluvax Done?]="N-M",0,1) AS [Flu Denominator], IIf([Flu Denominator]=0,0,IIf([Fluvax Done?]="Y",1,0)) AS [Flu Numerator], IIf([Pneumovax Done?]="N-M" Or [01 - Beneficiary Demographics]![Age]<65,0,1) AS [Pneumo Denominator], IIf([Pneumo Denominator]=0,0,IIf([Pneumovax Done?]="Y",1,0)) AS [Pneumo Numerator], IIf(([Colorectal Screen Done?]<>"N-M" Or [Colorectal Screen Done?] Is Null) And [01 - Beneficiary Demographics]![Age]>=50 And [01 - Beneficiary Demographics]![Age]<=75,1,0) AS [Colorectal Denominator], IIf([Colorectal Denominator]=0,0,IIf(([Colorectal Screen Type]="FOBT" And [Colorectal Screen Date]>=#1/1/2013#) Or ([Colorectal Screen Type]="Sigmoidoscopy" And [Colorectal Screen Date]>=#1/1/2009#) Or ([Colorectal Screen Type]="Colonoscopy" And [Colorectal Screen Date]>=#1/1/2004#),1,0)) AS [Colorectal Numerator], IIf(([Mammogram Done?]<>"N-M" Or [Mammogram Done?] Is Null) And [01 - Beneficiary Demographics]![Age]>=40 And [01 - Beneficiary Demographics]![Age]<=69 And [01 - Beneficiary Demographics]![GENDER]="F",1,0) AS [Mammo Denominator], IIf([Mammo Denominator]=0,0,IIf([Mammogram Done?]="Y" And [Mammogram Date]>=#1/1/2012#,1,0)) AS [Mammo Numerator], IIf([Tobacco Use Screen Done?]="N-M" Or [01 - Beneficiary Demographics]![Age]<18,0,1) AS [TobUse Denominator], IIf([TobUse Denominator]=0,0,IIf([Tobacco Use Screen Done?]="Y" And ([Tobacco Use Status]="Non-User" Or ([Tobacco Use Status]="User" And [If User Cessation Counsel Done?]="Y")),1,0)) AS [TobUse Numerator], IIf([BMI Taken?]="N-M" Or [BMI Taken?]="N-P" Or [01 - Beneficiary Demographics]![Age]<18,0,1) AS [BMI Denominator], IIf(([Age]>64 And [bmi taken?]="Y" And [BMI Calculation]>=23 And [bmi calculation]<=30),"Y",IIf(([age]<=64 And [bmi taken?]="Y" And [bmi calculation]>=18.5 And [bmi calculation]<=25),"Y","N")) AS [BMI Normal Flag], IIf([BMI Denominator]=0,0,IIf([BMI Taken?]="Y" And ([BMI Normal Flag]="Y" Or ([BMI Normal Flag]="N" And [If Not Normal Follow-Up Plan Done?]="Y")),1,0)) AS [BMI Numerator], IIf([Fall Risk Assessment Done?]="N-M" Or [Age]<65,0,1) AS [FallRisk Denominator], IIf([FallRisk Denominator]=0,0,IIf([Fall Risk Assessment Done?]="Y",1,0)) AS [FallRisk Numerator], IIf([Depression Screening Done?]="N-M" Or [Depression Screening Done?]="N-P" Or [Age]<12,0,1) AS [Depression Denominator], IIf([Depression Denominator]=0,0,IIf([Depression Screening Done?]="Y" And ([Depression Screen Result]="Negative" Or ([Depression Screen Result]="Positive" And [If Positive Follow-Up Done?]="Y")),1,0)) AS Depression
FROM [01 - Beneficiary Demographics] INNER JOIN [03 - All One-to-One Measures] ON [01 - Beneficiary Demographics].HIC = [03 - All One-to-One Measures].HIC;
0

LVL 74

Expert Comment

ID: 39592241
...
If it were me, I would really start to use functions for systems like this.

A Function will allow you to:
Use the VBA debugging tools
Step though the code one line at a time
Create and View variables and their values
...etc

It is a lot easier to troubleshoot complex If Logic in this form:
If Something ="A" and Something ="b" then
'Do something
else
'Do something else
end if
...because you can add as many conditions as you like very simply, and not have to worry about all the parentheses.

For example, this:
WhatTotest:IIF(Age=21 and Gender=Male,"CheckTestoserone",IIF(Age=18 and Gender=Female,"CheckEstrogen","n/a"))

Becomes this:
Function WhatToTest(Age as byte, Gender as string) as string
IF Age=21 and Gender=Male Then
WhatToTest="CheckTestoserone"
ElseIf Age=18 and Gender=Female Then
WhatToTest="CheckEstrogen"
else
WhatToTest="n/a"
end if

Then call this function in your query:
SELECT Fld1, Fld2, WhatToTest(Age,Gender) as TestToPerform

I would also try to stay away form Y and N for your tests, I would rather use boolean
0=False or No
-1=True or Yes

But all of this aside I don't have the patience or time to evaluate all of that.
(but perhaps another expert can spot something)

For me, it would be much simpler if you posted a sample of your database following these guidelines:

1. Back up your database(s).
2. If the database is split, combine the front and back ends into one database file.
3. Remove any startup options, unless they are relevant to the issue.
4. Remove any extraneous records unless they are relevant to the issue.
5. Delete any objects that do not relate directly to the issue.
6. Remove any references to any "linked" files (files outside of the database, Images, OLE Files, ...etc)
7. Remove any references to any third party Active-x Controls (unless they are relevant to the issue)
8. Remove, obfuscate, encrypt, or otherwise disguise, any sensitive data.
9. Unhide any hidden database objects
10. Compile the code. (From the VBA code window, click: Debug-->Compile)
11. Run the Compact/Repair utility.
12. Remove any Passwords, Security and/or login prompts.
13. If a form is involved in the issue, set the Modal and Popup properties to: No
(Again, unless these properties are associated with the issue)
14. Post the explicit steps to replicate the issue.
15. Test the database before posting.

In other words, ...post a database that we can easily open and immediately see and/or troubleshoot the issue.
Post the explicit steps to see the issue.
And if applicable, also include a clear, graphical representation of the *Exact* results you are expecting, based on the sample data.

JeffCoachman
0

Author Comment

ID: 39592293
Jeff,

I will post something.  Once again, thanks for all of your help.

T_Van
0

LVL 74

Expert Comment

ID: 39592417
Yes, I just want to see everything broken out...

Then biggest obstacle is getting all the base values together...

I may come up with a simplified solution that you can adapt...
0

Accepted Solution

T_Van earned 0 total points
ID: 39628359
I was able to work around it by using Excel to collate the data instead.

Thanks for your help on this.
0

Author Closing Comment

ID: 39638303
It was easier to use Excel to collate my data than to submit the database to members and wait for additional responses.
0

## Join & Write a Comment Already a member? Login.

This article will show you how to use shortcut menus in the Access run-time environment.
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo â€¦
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filledâ€¦

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

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

#### Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!