How to add a calculated column using conditions in a query in MS Access 2010 - ms-access

I have two tables and from that I am generating a query. I have columns in my query with field type yes/no. These are basically columns to determine the race of a person. The user enters information in yes/no for various races. I want another calculated column in the query which checks for all other race columns and calculates values in it.
I have to check for a few conditions in for the values in columns
For example:
1) If Hispanic is chosen, the new column should say hispanic(no matter what other options are selected. This is like a trump card)
2) If more than one is selected, then new column entry should say "multi"
3) If none of the options are selected, it should say "unknown"
4) If exactly one of them is selected, then that race should be displayed
Can anyone help me with this? I am new to Access

I can't code it for you but I can point you in the right direction. What you want to do is take all the tests you explained above and put them in a coded format :
iif ( condition, value_if_true, value_if_false )
Since you have a lot of possible outputs i'd use something like a Case Statement where you can test for all the possibilities.
Follow this link if you need any info on how to code both type of statements (iif and case).
Once you have tried something like this, you can comeback with a specific question if you encountered a problem in the process.
Good luck with your database.

Related

SAP BO 4.2 SP07 inList clause in webi

Can i use another column in InList clause?
Example,
i have created a variable and below is the formula.
IF [query1.column1] inList ([query2.column2]) then SUM([query1.amountColumn])
Else 0
OR is it possible to put variable after inList in formula?
If not possible -- is there any other alternative to this?
I see two possible approaches. I will to use the eFashion universe for both solutions.
Solution #1
Here are my 2 queries to begin...
Run your queries. Click on the columns you want to compare, [query1].[column1] and [query2].[column2] in your case; [Query 1].[Month] and [Query 2].[Month] for me. Right-click and merge them. They must be dimensions and of the same data type.
Now create a variable based on [Query 2].[Month Name] which you can filter on to eliminate the results from Query 1 that do not match up to anything in Query 2.
[UV Month Name]=[Query 2].[Month Name]
The key here is you need to change the Qualification to "Detail" and set the Associated Dimension to what we just merged by clicking three dots to the right. Choose [Month Name] not from either query, but the merged dimension.
Now build out your table with whatever object you want from Query 1 and add in the variable we just created.
Now add a filter on that variable to only show row where it is not null.
And you are done.
Pros
Works when limiting query (query2) has a relatively large number of values (compare to Cons for Solution #2).
Cons
More complicated to set up
May run into universe or performance issues related to query being filtered (query1).
Solution #2
Building upon Solution #1, I duplicated Query 1 and renamed it Query 3. Now you can choose "Results from another query" to get the [query1].[column1] InList ([query2].[column2]) logic you want.
If you take this approach then you don't need to do the merge, variable, and filter. The results of the query are filter before being returned by the report.
Pros
Simple
Cons
The number of values coming from your second query must be relatively small. It varies by database or maybe even your universe. I have found if it is over 1,000 values I get an error when I run the query that it is "too complex".

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.

Populating multiple records from access form

My company keeps records of job codes & purchase order numbers as machines are used, etc. I am trying to create a form where an individual can populate a job number and then input the time a machine was used (machine name and hours) for that job along with a few other fields. My primary question is if there is a way to populate one job code for multiple machines/hours. This would eventually be used for employee time keeping also.
You can do this by creating an update query.
See Create and run an update query or Update Queries in Microsoft Access
Not sure much of a newbie you are, but here's what I would do from start to finish.
1) Create an update query by going to Create -> Query Design.
2) Add your table to the query
3) In the upper-left part of the screen, "select" will be selected. Click on "update" to create an update query
4) In your query criteria, add whatever criteria you need to make it apply to multiple machines or hours. For example machines that have worked between January 1, 2017 and June 1, 2017 you would add (you need #'s for dates in queries)
=#1/1/2017# And <=#6/1/2017#
to your date field. Or let's say you have three machines named A1, B2, and C3. You only want to apply to job code to A1 and B2. Under the field that denotes your machine name your criteria would be:
"A1" or "B2"
Whether you use the date or machine field, you'll need to use the update query to input the job code for all applicable cases. let's say you want to make the job code "Code124" for all people who meet the criteria you specified. Under the Update to line in your query, type in "Code124" and hit "Run" (the icon in the upper left corner with an explanation point. That should do it.

Report containing sums from different queries in Access

I am currently working with different tables and queries in Access and I can't find a way to do something very simple. I have the following :
Two queries, qry1 and qry2
One table, tbl1
Both queries and the table have a "NET" field of type float (or double)
What I'd like to do is create a very simple report which would give me the total of the NET column for each of those three objects. I have tried to insert a text box in a blank report and selecting sum(NET) on qry1 in Control Source but it doesn't work, it simply prints '#Error' with no more information.
If I use 'Add Existing field' and drag&drop 'NET' from tbl1 and then edit it to add sum it works but it is repeated for each row which is obviously not what I want. It feels like I'm missing something here or that I might not be using the right tool.
Thanks in advance for your help!
Have you considered the DSum() function? Create three text boxes and set the control source for each text box as follows:
=DSum("NET", "qry1")
=DSum("NET", "qry2")
=DSum("NET", "tbl1")
Note: Aggregate functions (e.g., DSum, DLookup, etc.) have poor performance compared to performing the calculations within a query. It's not clear from your question whether that's an option for you or not.

Concatenating Row Values in SSRS?

I'm trying to concatenate a particular record into one field to avoid multiple rows for the record. The issue is that a drive may contain multiple shifts in which each shift may be assigned a different vehicle.
Screenshot below shows what is happening:
Both records show the same drive, but the two shifts. I'd like to get the vehicles column to concatenate all vehicles into one field (Vehicles).
My attempt at an expression is:
=Fields!ShortDesc.Value & "," & Fields!ShortDesc.Value
Which obviously isn't working. Any suggestions on what to do to get this working correctly?
Easy solution would be to concat in database layer. See following question and answer. If you need to use SSRS solution, answer is running value function, an example here.