473,379 Members | 1,530 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,379 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 1455
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.