473,385 Members | 1,587 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

DCount and negative number

I am trying to count the number of fields that have a range of negative numbers.
IDF_Log: Table
[Temp (C)]: Temperate range in Celsius(set as text format due to some temps are unknown)
I would like to keep the temperature in Celsius due to all the data but may be forced to convert the data to kelvin so there are no negative numbers.

I have tried the below code and get an "#ERROR" error
Expand|Select|Wrap|Line Numbers
  1. =DCOUNT("[ID1]", "IDF_Log", "[Temp (C)] >= -30 AND [Temp (C)] <= -5")
Expand|Select|Wrap|Line Numbers
  1. =DCOUNT("[ID1]", "IDF_Log", "[Temp (C)] >= (30) AND [Temp (C)] <= (5)")
returns 32 which is incorrect
Expand|Select|Wrap|Line Numbers
  1. =DCOUNT("[ID1]", "IDF_Log", "[Temp (C)] >= '-30' AND [Temp (C)] <= '-5'")
Any insight as to how to depict negative numbers in the criteria is greatly appreciated.
Aug 30 '15 #1

✓ answered by Rabbit

It's not because of negative numbers. It's because you're using text data type to store numbers. So it's trying to convert text to a number but it can't for some of your data so it errors out.

For those that don't have a known temperature, they should be stored as null and the data type of your column should be a number.

4 1457
jimatqsi
1,271 Expert 1GB
You don't say what is stored when the value of a temperature is unknown. You could try referring to CINT([Temp C]) in order to convert the temperature to an integer - or to CDBL instead of CINT if you need decimal places.

If the unknown temps are stored as some string you could also use iif statements like this:
Expand|Select|Wrap|Line Numbers
  1. iif(IsNumeric([Temp C],CINT([Temp C]),[whatever value you want for missing temps])
You can also avoid converting if you simply add some value when storing the number and subtract that same number when reading - okay so that's still a kind of conversion. But what's the point of avoiding negative numbers?

Jim
Aug 30 '15 #2
Jim
The unknown values are labeled as "unk" in the table. I believe that my question is misunderstood. I want to count the number of values that are within the range listed above. So for example if I had the following values in the table (-25, -10, 5, 20, -2, -15) the DCount formula would return the number 3.
Aug 30 '15 #3
Rabbit
12,516 Expert Mod 8TB
It's not because of negative numbers. It's because you're using text data type to store numbers. So it's trying to convert text to a number but it can't for some of your data so it errors out.

For those that don't have a known temperature, they should be stored as null and the data type of your column should be a number.
Aug 30 '15 #4
Rabbit,
Thanks for your help. Changing data type to number fixed my issues.
Aug 31 '15 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

25
by: Jason | last post by:
Hi, below is example code which demonstrates a problem I have encountered. When passing a number to a function I compare it with a string's size and then take certain actions, unfortunately during...
16
by: JKop | last post by:
Take a class like the following: class Finger { public: double length; }
7
by: hasanainf | last post by:
Hi all, I have two querys QueryPurchased ProductID Location TotPcs Prod1 Loc1 100 Prod2 Loc1 50 Prod3 Loc1 150 Prod3 Loc3 150
5
by: Subrahmanyam Arya | last post by:
Hi Folks , I am trying to solve the problem of reading the numbers correctly from a serial line into an intel pentium processor machine . I am reading 1 byte and 2byte data both positive...
1
by: Wayne | last post by:
There is probably a simple solution to this but: I have a textbox that is bound to a number field in a table. The field type is "double". If I enter a negative value directly into the table it...
20
by: Casey | last post by:
Is there an easy way to use getopt and still allow negative numbers as args? I can easily write a workaround (pre-process the tail end of the arguments, stripping off any non-options including...
5
by: wilboy | last post by:
Hi everyone I have a small problem here. I only want return positive number or zero when - . Eg. - = 48.50 - 52.60 = 0 78.20 ...
3
by: Peng Yu | last post by:
Hi, I don't understand why rbegin() -rend() gives a negative number. Since rbegin() + 1 gives the one before the last element, I think rbegin() - rend() should give a positive number. ...
1
by: santoshsri | last post by:
Hi All, My C# web application calls a webservice to process a report. It sends XMLs as parameter and in response gets an XML node which stores Binay datatype bin.base64. It makes an instance of...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.