473,396 Members | 1,847 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,396 software developers and data experts.

Convert Excel Formula to Access for use

I have a formula used in Excel that I am trying to convert for use in a query. the original formula is:

Expand|Select|Wrap|Line Numbers
  1. =IF(AND(#REF!>=0,#REF!<=66800),(#REF!*((0.7-1)/(66800-0))+1),IF(AND(#REF!>66800,#REF!<=500000),((#REF!*((0.4-0.7)/(308000-66800))+0.783085)),0))
I have attempted the following but keep getting syntax errors..... tell me what I am doing wrong so that I can understand how to fix it and to perform this type of conversion on other formulas.

Expand|Select|Wrap|Line Numbers
  1. PPM Score: IIf(([PPM]>=0,[PPM]<=66800),([PPM]*((0.7-1)/(66800-0))+1),IIf(([PPM]>66800,[PPM]<=500000),(([PPM]*((0.4-0.7)/(308000-66800))+0.783085)),0))
May 29 '07 #1
6 7115
JConsulting
603 Expert 512MB
I have a formula used in Excel that I am trying to convert for use in a query. the original formula is:

Expand|Select|Wrap|Line Numbers
  1. =IF(AND(#REF!>=0,#REF!<=66800),(#REF!*((0.7-1)/(66800-0))+1),IF(AND(#REF!>66800,#REF!<=500000),((#REF!*((0.4-0.7)/(308000-66800))+0.783085)),0))
I have attempted the following but keep getting syntax errors..... tell me what I am doing wrong so that I can understand how to fix it and to perform this type of conversion on other formulas.

Expand|Select|Wrap|Line Numbers
  1. PPM Score: IIf(([PPM]>=0,[PPM]<=66800),([PPM]*((0.7-1)/(66800-0))+1),IIf(([PPM]>66800,[PPM]<=500000),(([PPM]*((0.4-0.7)/(308000-66800))+0.783085)),0))

PPM Score: IIf(([PPM]>=0,
[PPM]<=66800), <--true part
([PPM]*((0.7-1)/(66800-0))+1), <---false part. It stops here without another IIF
IIf(([PPM]>66800,[PPM]<=500000),(([PPM]*((0.4-0.7)/(308000-66800))+0.783085)),0))
May 29 '07 #2
Syntax error (comma) in query expression.

Expand|Select|Wrap|Line Numbers
  1. PPM Score: IIf(([PPM]>=0,
  2. [PPM]<=66800), 
  3. ([PPM]*((0.7-1)/(66800-0))+1), 
  4. IIf(([PPM]>66800,[PPM]<=500000),(([PPM]*((0.4-0.7)/(308000-66800))+0.783085)),0))
May 29 '07 #3
JConsulting
603 Expert 512MB
Syntax error (comma) in query expression.

Expand|Select|Wrap|Line Numbers
  1. PPM Score: IIf(([PPM]>=0,
  2. [PPM]<=66800), 
  3. ([PPM]*((0.7-1)/(66800-0))+1), 
  4. IIf(([PPM]>66800,[PPM]<=500000),(([PPM]*((0.4-0.7)/(308000-66800))+0.783085)),0))

Expand|Select|Wrap|Line Numbers
  1. PPM Score: IIf(([PPM]>=0 and [PPM]<=66800), ([PPM]*((0.7-1)/(66800-0))+1), 
  2. IIf(([PPM]>66801,[PPM]<=500000),(([PPM]*((0.4-0.7)/(308000-66800))+0.783085)),0))
  3.  
is there a chance that PPM will be null?
May 29 '07 #4
PPM is
Expand|Select|Wrap|Line Numbers
  1. PPM: (([totalrejected]/[totalreceived])*1000000)
whereas
Expand|Select|Wrap|Line Numbers
  1. totalreceived: NZ([T.totalreceived],0)
&
Expand|Select|Wrap|Line Numbers
  1. totalrejected: NZ([W]![totalrejected],0)
so all Nulls are coverted to 0, so I would say that no there can not be any nulls.

Let me be more specific: here is the SQL for the Query

Expand|Select|Wrap|Line Numbers
  1. SELECT T.VendName, NZ([T.totalreceived],0) AS totalreceived, NZ([W]![totalrejected],0) AS totalrejected, (([totalrejected]/[totalreceived])*1000000) AS PPM, ([totalreceived]-[totalrejected])/[totalreceived] AS [Yield %], ([totalrejected]/[totalreceived]) AS [Reject %]
  2. FROM qryExternalTOTrec AS T LEFT JOIN qryExternalTOTrej AS W ON T.VendName = W.suppName
  3. ORDER BY T.VendName;
May 29 '07 #5
JConsulting
603 Expert 512MB
PPM is
Expand|Select|Wrap|Line Numbers
  1. PPM: (([totalrejected]/[totalreceived])*1000000)
whereas
Expand|Select|Wrap|Line Numbers
  1. totalreceived: NZ([T.totalreceived],0)
&
Expand|Select|Wrap|Line Numbers
  1. totalrejected: NZ([W]![totalrejected],0)
so all Nulls are coverted to 0, so I would say that no there can not be any nulls.

Let me be more specific: here is the SQL for the Query

Expand|Select|Wrap|Line Numbers
  1. SELECT T.VendName, NZ([T.totalreceived],0) AS totalreceived, NZ([W]![totalrejected],0) AS totalrejected, (([totalrejected]/[totalreceived])*1000000) AS PPM, ([totalreceived]-[totalrejected])/[totalreceived] AS [Yield %], ([totalrejected]/[totalreceived]) AS [Reject %]
  2. FROM qryExternalTOTrec AS T LEFT JOIN qryExternalTOTrej AS W ON T.VendName = W.suppName
  3. ORDER BY T.VendName;
this should do then.

Expand|Select|Wrap|Line Numbers
  1. PPM Score: IIf([PPM]>=0 and [PPM]<=66800, ([PPM]*((0.7-1)/(66800-0))+1), 
  2. IIf([PPM]>66800 and [PPM]<=500000,(([PPM]*((0.4-0.7)/(308000-66800))+0.783085)),0))
  3.  
unless I missed a parens somewhere.
May 29 '07 #6
Worked!! Thanks a million!!
May 29 '07 #7

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

Similar topics

3
by: Carlos Magalhaes | last post by:
Hey All, I am doing some excel automation using the excel COM. I can do most of the functions and its working well until I come across a formula. I can run a formula and insert the formula...
4
by: David_from_Chicago | last post by:
What I am trying to do is to simulate the LINEST functionality from Excel in Access through VBA. When I use LinEst in Excel I can get back five statistical results. Here are is the formula array...
3
by: toffee | last post by:
Hi all, I got a pre-formatted spreadsheet. would it be possible using js to copy the data from a table on the current webpage, open the spreadsheet and paste the content ? if so, anyone got any...
2
by: CodeMonkey775 | last post by:
I'm having problems passing a variable to a method which is executed and compiled using CodeDom. The situation is I have a List<CellData> with cells, each containing a formula (like Excel). I am...
3
by: skiddle | last post by:
I've got an Excel formula that calculates the total business hours that a help desk ticket is open. As one would expect, it factors out holidays and non-work hours. What would be the corresponding...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
3
by: sejal17 | last post by:
hello Can any one tell me how to read multiple worksheets from a single excel file.I have stored that excel in xml file.so i want to read that xml that has multiple worksheet.And i want to store...
2
by: welshkaiboy | last post by:
Due to the size of the data I have to manipulate I need to apply a excel formula in access which determines date of manufacture from a serial number 716001 so I use...
2
by: rtilson | last post by:
I am not sure why excel and access use the same method in formula. I am not access expert but been trying to figure it out. Here is the excel formula that I would like to use in access expression...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.