Calculated Field Within a Query in Access 2016 - ms-access

I realize that this question is quite basic. And I have found various answers on various other forums - all of which use SQL which for the purpose of this assignment (it is for school) I cannot use. I have to physically type the answer into the Field box.
The question reads as such: "Add a calculated field in the third column. Name the field ExtendedAmount. This field should multiply the quantity ordered (from the Order Details table) by the unit price for that item (from the Products table). This will calculate the total amount for each order. Format the calculated field as Currency and change the caption to Total Dollars. Change the Total row to Sum."
I have attached a screenshot of what I tried, in Design View, as well as the relationships of the tables required for the question and other parts of the query. When I click "Run" that is where I hit a snag - it provides and other box which says, "Enter Parameter Value" which as I understand it should be supplied by the Order Details Table.
Does anyone have any idea as to what I can do to fix this? Here is the expression I built as well --- ExtendedAmount: ([QuantityOrdered]*[UnitPrice])
Thanks,
Josh

The quantity field is called [Quantity], not [QuantityOrdered]. Adjust your expression accordingly.

Related

How to customize TaxReport_IT - report SSRS?

I would like to custom the Report SSRS TaxReport_IT, I need to add a new field in order to use in to SyntethicReport Design.
(for example)
The classes involved seems these:
TaxReport_IT
TaxReportDP_IT
TaxReportController_IT
TaxReportContract_IT
Tables involved:
TmpTaxReport_ITSummary
TmpTaxReport_IT
TaxReportTmp_IT
Are there others? Are there some Queries involved?'
I added the new fields in to table _TmpTaxReport_IT_, and I pupulated the related tables
I'm sure, in to the method I pupulated correctly the new Field (I have the values ​​that I expect), but when I print the Report I get a lower value. Seems like I don't take the total data set.
How can I add the new field and take the correctly total value?
I saved the data (about my custom field in a RegularTable) and the sum is correct, but I have mismatch when I print the report.
I think I skip some step to Report DataSet.
I use Dynamics AX 2012.
Thanks in advice!
I have an idea what could be wrong, but I'm making some assumptions. If they are not correct, please edit your question to clarify.
From your screenshot, it looks like you want to add your new custom field in the header section of the report design. I'm assuming the expression of that field looks similar to
=First(Fields!MyCustomFIELD.Value, "TaxReportDS_IT")
Note the First key word in that expression. This indicates that the value for that field should be taken from the first of the records of the report's dataset.
I'm assuming that you calculate the value of the field while the records in table TaxReportTmp_IT are being created so that each record has a different value. Maybe it is a sum of some other field, so the first record would have the smallest value and the last record the highest.
If all those assumptions are correct, you can fix this by changing the First keyword to Last. This indicates that you want to take the value of the last record of the report data set.
See also the documentation of the Last Function.

If Else Statement in Access Table Field

I'm super confused how to apply the if/else statement in an Access table field, not a query. Please help! Here is what I'm required to do based on the table I constructed:
Fill in the overall rating field, using this formula: If the is available field is false, the overall rating is “pending”, regardless of the scores. Otherwise, if each rating score is 9 or above, the rating is ''excellent"; if the interview average is 9 or above and one rating score is less than 9, the rating is ''very good"; if the interview average is less than 9 and one (or both) rating score is 8 or above, the rating is "erratic"; otherwise the rating is "reject".
click here to view the table
From Access 2010 onward you can indeed create calculated fields in a table. To do that, open the table in Design View, enter the name for the new column and choose Calculated as its data type.
Use the Expression Builder or any external text editor to build/write the expression for the calculated field. There is only a limited subset of functions available to be used in a calculated table field. So in this case the Expression Builder actually is helpful, as it shows only functions that can be used in this context.
To achieve the result as per your requirements, you will need an expression with several nested Iif-Function calls. (The Switch function is not available here.)
The actual expression will be same as you would use in a query.
This is how you can do it, if you really want to. – I agree with the commenters that in almost any case it would be better to use a query to do any calculation of this kind.

Calculating a percentage from two datasets in SSRS

I am having trouble calculating the percentage of positive answers to some survey questions on my report.
I have two data sets; one which lists each organisation and how many surveys they have completed and the second one which uses exactly the same query but adds a filter for whether the questions have been answered as 'YES'.
With 2 tablix's on my report I get two lists which are grouped by organisation and which show overall surveys answered on one table and positive answers in the other table.
What I need to be able to do however, is to create a percentage of how many positive answers each organisation has completed.
I have tried using a lookup but I seem to be getting the total of ALL organisations in each row instead of each organisation in each row.
Maybe I am going about this the wrong way but any assistance you can give would be greatly received.
I am using VS2013 using SSRS 12.0.2344.23 on a local SQL2014 database.
Thanks,
Alan
EDIT:
Here is my current report layout:
1st Tablix is linked to the 'PositiveAnswers' dataset
Organisation Name | Number of Surveys with positive answers
[OrgName] | CountDistinct([Learner_ID])
I then have another tablix which is linked to the 'AllSurveys' dataset
Organisation Name | Total Number of Surveys
[OrgName] | CountDistinct([Learner_ID])
The ONLY difference between the two datasets is filtering for positive answers.
I would like to find out the percentage of positive answers for each organisation but when I add a new column to the 1st tablix with the following expression it doesn't work as expected:
=CountDistinct([Learner_ID]) / CountDistinct(Lookup(Fields!Learner_ID,Fields!Learner_ID,Fields!_LearnerID,"AllSurveys"))
The Learner_ID field is what links the two datasets.
Thanks,
Alan
Conditionally sum it up I think. Assuming your field is called answer and your dataset called ExampleTable, here is what a cell might look like:
=Sum(Iif(Fields![answer].Value="Y",1,0))/CountRows("ExampleTable")

How do I select a specific column based on a variable in a MS Access query?

I have a large table with the following fields:
Date
Product_ID
AmountEUR_Field1
AmountEUR_Field2
AmountEUR_Field3
AmountEUR_Field4
AmountEUR_Field5
where each AmountEUR field represents the sales amount for a product.
The reason for having 5 different AmountEUR fields is that they are based on different Currency Rates (in example BeginingOfMonthRate, AverageMonthRate, EndOfMonthRate etc.).
I now want to copy a specific AmountEUR field to another table, but the AmountEUR field to be copied varies over time (sometimes it is AmountEUR_Field2, other times it is AmountEUR_Field5).
Therefore I need to select a specific column based on a variable from another table. (that variable should then have value between 1 and 5).
I have been thinking about making a new field called AmountEUR_ToBeUsed that is updated with the correct AmountEUR_Field, but that brings me back to the same problem of selecting the specific column I want copied.
Can a solution be made within the Access query designer, or do I need some VBA code?
You can just make this with the Access Query designer.
Specifically you will need the function IIF.
For instance, if you want to specify that before a date you wish to use AmountEUR_Field1, and otherwise AmountEUR_Field5 you can say:
IIF(somedate<#1/1/2011#,AmountEUR_Field1,AmountEUR_Field5)
Note, depending on the settings of your PC, you may have to say:
IIF(somedate<#1/1/2011#;AmountEUR_Field1;AmountEUR_Field5)

MS ACCESS - The problem of query

I want to ask some question, which about that"
Create a Query which accept two parameters,Restaurant and Category, and display results showing Branch, Category, Description, Date,
Quantity, Price and Total Sales, where Total Sales is calculated as Quantity * Price.
How can I do that? Please help me,thanks
You might like to read: http://support.microsoft.com/kb/304352
A couple of things that are needed to fully answer your qestion:
Version of MS Access
Table structure
But with that said, the item you are looking for is accessible in the Query By Example (QBE) grid.
Unless you are doing somethign very tricky with the data types, then you can just type the name of your 'variable' in the Where section of the grid in the column of the field that you wish to be applying the criteria to:
[*parameter*]
When you run the query, this will cause a pop up window to display that you can put your parameter into and hey presto - all solved.
As mentioned above, you should also read the KB article referenced. You can also use standard form syntax to link the parameter to a form field.
*formname.fieldname*