Summing values where one is #Error doesn't work

W

will

I have a raw_data table (originating from an external source and pasted
regularly into Access).
I have a normalised_query query based on raw_data and doing 'stuff'
including converting a text column to a number column. Where this
conversion fails (<1% of cases) the column in the query contains #Error.

I now want to run another query which includes a sum of that column, but
because the value #Error appears in one of the rows, the sum fails.

What's the simplest way around this?
 
D

Dale Fye

How are you converting the text to number?

You might try something like:

IIF(isnumeric([yourField]), Val([yourField]), NULL)

This would put a NULL in the numeric field if the data in that cell could
not be converted to a number, and would be ignored by the SUM( ) aggregate
function.

Dale
 
W

will

You hero - I just needed to use Val instead of Clng... didn't even need the
IIF as it defaults to a NULL if it can't handle it. I've been scratching my
head over that for hours and you solved in 2 mins - THANKS!

Dale Fye said:
How are you converting the text to number?

You might try something like:

IIF(isnumeric([yourField]), Val([yourField]), NULL)

This would put a NULL in the numeric field if the data in that cell could
not be converted to a number, and would be ignored by the SUM( ) aggregate
function.

Dale

--
Email address is not valid.
Please reply to newsgroup only.


will said:
I have a raw_data table (originating from an external source and pasted
regularly into Access).
I have a normalised_query query based on raw_data and doing 'stuff'
including converting a text column to a number column. Where this
conversion fails (<1% of cases) the column in the query contains #Error.

I now want to run another query which includes a sum of that column, but
because the value #Error appears in one of the rows, the sum fails.

What's the simplest way around this?
 
D

Dale Fye

Glad I was able to help.

--
Email address is not valid.
Please reply to newsgroup only.


will said:
You hero - I just needed to use Val instead of Clng... didn't even need the
IIF as it defaults to a NULL if it can't handle it. I've been scratching my
head over that for hours and you solved in 2 mins - THANKS!

Dale Fye said:
How are you converting the text to number?

You might try something like:

IIF(isnumeric([yourField]), Val([yourField]), NULL)

This would put a NULL in the numeric field if the data in that cell could
not be converted to a number, and would be ignored by the SUM( ) aggregate
function.

Dale

--
Email address is not valid.
Please reply to newsgroup only.


will said:
I have a raw_data table (originating from an external source and pasted
regularly into Access).
I have a normalised_query query based on raw_data and doing 'stuff'
including converting a text column to a number column. Where this
conversion fails (<1% of cases) the column in the query contains #Error.

I now want to run another query which includes a sum of that column, but
because the value #Error appears in one of the rows, the sum fails.

What's the simplest way around this?
 

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

Top