Queries :: Create Calculation Query That Uses Different Equations Under Certain Conditions
May 12, 2013
I want to create a calculation query that uses different equations under certain conditions. Here's specifically what I need:
If the "Cost_Category" field is "Full Price" then the query uses the following calculation:
Total_Cost: Sum(nz([Program_Cost])+nz([Millage_Fee])+nz([Auditorium_Cost]))
If the "Cost_Category" field is "BOCES" then the query uses the following calculation:
Total_Cost: Sum(nz([BOCES_Number_of_Participants])*nz([Cost_Per_Person]))
I have successfully created these two queries individually, but combining them doesn't seem to work. Here's what I wrote:
Total_Cost: IIf([Cost_Category]=Full Price,Sum(nz([Program_Cost])+nz([Millage_Fee])+nz([Auditorium_Cost])),
IIf(Cost_Category]=BOCES,Sum(nz([BOCES_Number_of_Participants])*nz([Cost_Per_Person]))
It keeps coming up with errors, saying that I misplaced a comma, parenthesis or quotation. I've tried playing with it, changing the syntax slightly but it doesn't seem to work.
View Replies
ADVERTISEMENT
May 16, 2013
I need to create a form that using combo boxes selects a product-size-quantity, and then calculates total price.I asume that I create a query to make the calculation from the form, but for the life of me, I can't fathom out how to do it.
View 3 Replies
View Related
Aug 11, 2006
Ok my goal is to have a calculation in a query that includes a bunch of addition, division, and multiplication. (It uses 10 pieces of data) I tryed typing it in the expression builder but it doesn't work. I don't know if I am setting it up wrong or putting it in the wrong spot or what. I've tried some different things and I either get a blank box in that field or I get a syntax error. Also is there any way I can put the info received by the equation into a field in my table? Thanks
View 2 Replies
View Related
May 15, 2013
I have a parameter query with a totals row that displays averages. Is there a way to have the average row use only specific records in its calculation based on one of the field's values WHILE still displaying all the records returned by the query.I want only data that has a "YES" value used in the average while still displaying the records marked as "NO"
View 1 Replies
View Related
Aug 6, 2014
I am needing a query to calculate elapsed time in business hours for each record selected (I normally base this on a date range). For the purposes of this query, business hours are defined as Mon-Fri from 7 AM until 9 PM.
So for example:
With a start time of 6:45 AM and an end time of 9 AM, the query would need to return 02:00 (in [h]:mm format).Likewise, with a start time of 7 AM and end time of 9 AM the query would also return 02:00.Is there any way to do this easily? Or at all for that matter? Is it possible to deal with weekends?
View 5 Replies
View Related
Aug 5, 2014
I am trying to set up a calculation between two values to show the percentage difference. In Excel, for example, I would have two values, £905,175 and £891,563, and I would enter =A1-G2)/ABS(A1), which would then return a plus or minus percentage value. how to do this in a query using Access 2010?
View 3 Replies
View Related
Mar 26, 2013
I have the following age calculation query:
Age: (Now()-[DOB])365
It works a treat! However, I do not want this to continue to calculate if the record has them as deceased - I want it to stop at their date of death.
I have a tick box that when selected indicates that this record has died, and a field where you can enter date of death.
Is there some way that via clicking this button, or by entering a date of death, I can stop the Age Query from calculating for just that relevant record, not all of them? If so, where to place the necessary VBA, etc?
View 8 Replies
View Related
Apr 13, 2015
I have a database with a Date of Birth field. I have a query with a field that calculates the age from the Date of Birth (DateDiff("yyyy",[Date of Birth],Date())+Int(Format(Date(),"mmdd")
As a criteria in this field I want to be able to select a minimum age, so >=[please input minimum age]
However the results are bizarre - sometimes it gives the right answer, and sometimes not. It seems to have a particular problem with ages above 10, which show up all the time.
View 5 Replies
View Related
May 8, 2013
I created a simple calculation query to add the values of three fields:
Program_Cost, Auditorium_Cost and Millage_Fee.
I followed the steps found here: [URL] ....
But it doesn't work. The query pulls the values for the relevant fields but doesn't actually calculate the total. What am I doing wrong? Here's the query's SQL:
SELECT [Event Information].Event_ID, Sum([Program_Cost]+[Millage_Fee]+[Auditorium_Cost]) AS Total_Cost, [Event Information].Program_Cost, [Event Information].Auditorium_Cost, [Event Information].Millage_Fee
FROM [Event Information]
GROUP BY [Event Information].Event_ID, [Event Information].Program_Cost, [Event Information].Auditorium_Cost, [Event Information].Millage_Fee;
View 2 Replies
View Related
Feb 20, 2015
I'm trying to get a query to perform a calculation and round the results.
The fields that I am running the calculation and am trying to round are Data Type Number, properties Field size Single and decimal places Auto.
I have tried the built in function described in Allen Browne's site to no avail.
[URL]
I have tried rounding the individual fields and then adding result.
I have also tried rounding the result (as attached).
View 11 Replies
View Related
Nov 21, 2014
I have a query with a DateSerial Calculation field that I would like to filter the query by. The DateSerial calculates the same day of every year (5/31/"YYYY"). When I try to add a criteria sort to this field, I get a data mismatch error. Here is the code: ThirdMay: DateSerial(Year(DateAdd("yyyy",3,[LastDayYear])),5,31).
How do I get only dates due in 2015 to show? I have tried all the standard date criteria to no avail.
View 1 Replies
View Related
Dec 9, 2013
I have played with this problem for 3 days and have come close but not quite solved it. My problem, I have several drivers delivering several orders, the orders are named 101, 102 and so on lets say to 150. Due to locations of the drivers, some deliver more orders then others. I want to be able to create a report that looks like
"Driver #1 101 - 106"
"Driver #2 107 - 110"
Driver 1 delivered 6 orders. Driver #2 delivered 4 orders and so on.
I have tried the 'count" which gives me the number of orders per driver but having trouble figure out the design of the calculation in the query.
View 2 Replies
View Related
Jan 22, 2014
I am trying to calculate the total hobbs time (Ending Hobbs - Starting Hobbs = Total Hobbs) based on a user inputed date range. The query that I created (see attachment) doesn't seem to give me what I'm wanting.
View 14 Replies
View Related
Apr 24, 2013
I have a database that has 2 forms. After submitting the first form, the user should complete the second form within 24 hours. The first form stores the Date/Time the form was submitted. I want to be able to run a query and have a column in the query that is "Time Remaining". In non-technical terms, this column would be: Date/Time form submitted + 24 hours - Current date/time.
View 3 Replies
View Related
Jul 28, 2014
apply my situation / formula to others who had similar questions, but I get the #error output with no messages from access telling me what I did to cause this.
What I'm trying to do is create a formula that checks if two conditions are met, then applies an output. So I have a starting location [StartLocation] and [Stop2]...Both can be a small variety of locations.
Currently I have as follows:
Leg1: iif([StartLocation]="Location A" AND [Stop2]="Location B",500,0)
The formula would run longer in the end, going up to 10 stops, nesting the ifs and checking multiple locations for each stop.
Both my conditions are Text, and I want a number output depending on the location. Is it a simple error I'm looking past and missing? Or is what I'm trying not possible, I feel like it should be relatively easy. Access give me no trouble for save and running, but it outputs #error.
View 2 Replies
View Related
Jun 12, 2014
From a performance perspective, does it matter in what order a number of clauses are specified ? For example if many records satisfy ConditionA but few records satisfy ConditionB, is it better to put ConditionB first ?
SELECT Fields FROM Table WHERE ConditionA and ConditionB
or
SELECT Fields FROM Table WHERE ConditionB and ConditionA
View 1 Replies
View Related
Mar 22, 2013
I have the following query. I got an error when I ran it.
Code:
SELECT COUNT([encounter_number] WHERE status = 'Death')/ COUNT([encounter_number]) AS Death Ratio, tbl_test.facility_type AS Type,
FROM tbl_test
GROUP BY tbl_test.facility_type;
I think the problem is that first WHERE clause inside.
View 2 Replies
View Related
Dec 21, 2013
1. I created a table that contains information about people and their details (mainly numerical info).
2. I created a form containing a command button and a label.
3. I have written a VBA script under the button so that when the button is pressed, the result of the calculation appears as the caption on the label.
My problem is...How do I get the script to run so it does the calculation for every record and places the result as a field in a query.
View 2 Replies
View Related
Jul 24, 2013
I am trying to make a query that outputs the minimum "Need Year" AND ALSO if the need year was equal to 9999 it shows "NO DATA".
This is what I have so far for checking the minimum value:
field: Need Year: MinofList(PMS_output!pqi_ny,PMS_output!iri_ny,PMS_ output!sdi_ny,pms_output!sai_ny)
I am not sure if I should be putting it in the criteria to check whether this minimum value (need year) equals to 9999 or not and if it does, it says "NO DATA" instead of 9999.
View 3 Replies
View Related
May 10, 2005
This being my first post, I hope to explain myself well enough. I am working on a database to do estimations. I will be starting with three main tables - Jobs,items & options. There are options that can be purchased for each item. My problem is that the option price's are unique. Example: There are door hinge options which will need to be multiplied by the number of doors (which is a field) and there are other options which are multplied by the length (another field). Is there a simple way to accomplish this? This may sound stupid but I was wondering if it would be possible to have a equation field for each option???
View 3 Replies
View Related
Jan 24, 2006
I have a simple problem that I can’t seem find any help for. I’ve tried searching and browsing the forums with no luck. I have a Boolean (yes/no) column that I would like to be dependent on an equation containing fields in a table. The equation is simple: I have three columns I’ll call them A, B and H.
The Equation is: A*12+B<H
If it’s true then the field will equal yes, if the equation is false then the field equals no.
I’d like to have this in a query that I can base a report off of. I know very little about SQL or VBA so when I see SQL or VBA terms used I can’t always tell what they mean. So if someone could tell me what I need to do I’d also know where to put it. Thanks A bunch!
View 6 Replies
View Related
Mar 19, 2013
I am hoping to do a report all my queries in my Database.
I have managed to use some sql code to list the queries which is the following:
SELECT MSYSOBJECTS.Name
FROM MSYSOBJECTS
WHERE (((MSYSOBJECTS.Type)=5) AND ((Left([NAME],1))<>"~"));
But i cant seem to get any further i would also like to include the creation date, the description if any, the tables associated with each query, as i know i have a good few queries which maybe duplicates i just want to clean it up.
View 2 Replies
View Related
Jul 11, 2005
I'm trying to take a database from MS database (Works 7.0) into Access 2002. I've done this before by saving it as a DBase IV file and then opening it as such into access. However, this time I need the EQUATIONS to transfer as well, not just the values. I care little about the form view, or even the values themselves, but need the equations to transfer. Please advise. Thanks. :confused:
Mike S in ohio
View 1 Replies
View Related
Aug 9, 2005
Hi friends,
I had two tables parent(f1) , child(f1,f2,f3).
I had to display f3 value for parent(f1) when f1 has only one f2,
if f2 values are more than one for single f1 and if all f3 values are 0 then
i should display f3 as 0, else if some values for f3 are nonZeros and some are Zeros then
is should display f3 value as '-'.
How to do this?
please any suggestions?
Thanks.
View 1 Replies
View Related
Aug 9, 2007
I am so frustrated right now that I could scream. I have a database which tracks attendance and referrals for a networking organization - it meets weekly on Thursdays. It has a report which displays totals of both attendance and referrals for each weekly meeting for an entire month. The problem I am having is related to the fact that some months have 4 Thursdays and some have 5. If I get my queries to display the meeting dates correctly for the 4-Thursday months, then it displays incorrectly for the 5-Thursday months, and vice versa.
Is there any way to put a criteria on a missing record? If I could have it just populate the 5th week with spaces or null when it doesn't exist for that month, it would make my life a lot easier.
I can send a copy of the database to anyone who thinks they can help. It's too big to post.
View 8 Replies
View Related
Mar 23, 2005
I have a filed and I want to find out its length then in the next column i have to add the data like if filed 1's length is 1 then it should be 000+field1.value, if it is 2 then 00+field1.value, if it is 3 then 0+field1.value and so on...any help is appreciated , thanks
View 2 Replies
View Related