How to build an expression in a total row in MS Access - vba

In MS Access I need to build an expression in the total row of a table and I don't know how to do it.
for example the 2nd column of this table says whether the 1st column is positive or negative
Number ......... Sign
10...............pos
-5...............neg
20...............pos
-15..............neg
now in total row the 1st column is sum and the 2nd is the sign of the sum
10...............pos
I have searched the net and my training resources but I couldn't find a clue
I would be glad if someone help me

Related

SQL Query on Seperating into Category

I have two columns, Type of asset and Total Amount Sale. I want to divide them into categories, high value and low value. The type of asset are PC240, PC250, PC400, PC500, PC1000.
If I were to set the minimum sale to the following. Please can someone help me how would I do it. Do I need to create another table to input this Minimum Sale?
Note: this minimum sale I got it from Excel file.

Qlikview: Total of calculated metric based on calculated dimension

I started working on Qlikview a week back and I am working on this dashboard.
I have a particular requirement which I am not able to achieve:
So, I have a calculated dimension "Categories" added in my script which based on certain conditions tags each name as SLEEPERS,STARS,WEAKLINKS etc.
Now, I have flagged the names based on certain condition which works fine.
The issue is, I want the sum of those flags on the level of calculated dimension CATEGORIES(SLEEPERS, STARS..etc) and my month field.
I am not able to achieve it because, the flag itself is a calculated field so sum of calculated field doesn't work. I tried using aggr, function but it returns zero for all rows. I am not sure why. in the aggr function I use the sum(Aggr(Flag,MONTH,Categories))
Can someone suggest a work around for this? I have attached the screenshot of the report for better understanding of the requirement

Calculating the average percentage of a bunch of figures in Excel?

Basically, I'm trying to calculate the total average outage hours of a worksheet I'm working with, however I'm trying to have it further broken down.
Here is a picture of the Excel Sheet:
Excel Calculations
(Not allowed to add embedded pictures yet :( - 10 reputation needed, sorry!)
Pretty much, I'm trying to calculate what the average up-time is for the month, by calculating the average downtime and then subtracting it from 100.00%
What I've got works, but I'm trying to workout whether the Outage Hours column can be scrapped, and the total can be calculated with perhaps just a larger formula.
Here is a link to the spreadsheet: https://www.dropbox.com/s/msowjndootd2hh2/Spreadsheet%20Calculations.xlsx?dl=0
Thanks in advance!
Just to clarify, you're looking for the result from the second column without having to include the second column, correct?
Since the second column is just the remaining difference (from 1.00) of the first column, then to get the result, all you have to do is take the remaining difference for the maximum overall to the total sum of the first column.
Meaning (assuming 12 months)...:
=12-SUM(B4:B15)
(Substitute 12 for however many months to be summed)
EDIT: OP is looking for =AVERAGE(B4:B15)

Trying to SUM a formula field based on constraints from another field

A little background on the report:
This is a productivity report for our employees working at our business. We determine their productivity based on the duration of the visits with clients. Some of our employees offer group sessions. They charge each client within the group, even though they are only giving, for example, one hour of service, they can bill for 10 hours if there are 10 people in the group. We determine what service they gave by service codes.
So, I have two fields in this formula, a service code field and a duration field.
The duration field is initially a STRING field from the database, even though it only gives number data, so I change it to a numberVar. The service code field is also a string field, and it sometimes does contain characters and numbers.
What I need Crystal Reports to do is take the sum of the duration. However, if the service code is, say, "1000", it must first divide the duration by 3 before summing it. This is where I get caught up.
Here's my code for the duration:
local numbervar num1;
If GroupName ({billing_tx_charge_detail.v_SERVICE_CODE})="1530" then
num1 := ToNumber({billing_tx_charge_detail.v_duration})/3
else num1 := ToNumber({billing_tx_charge_detail.v_duration})
Then I do a separate formula for the sum, named sumDuration:
Sum(#duration)
I get the error that this field cannot be summarized. After searching Google for two days I have found that Crystal cannot summarize fields or formulas involving constants. If I simply say:
local numbervar num1;
num1 := ToNumber({billing_tx_charge_detail.v_duration})
then I can summarize #duration. What am I missing? It has to be something simple, but I'm just not seeing it. Is there a way to create a custom function to accomplish what I am trying to get here? Or is it even simpler than that?
One person suggested creating a SQL command in order to do the calculations before the data gets to the report. I am a SQL newb so I had no idea where to even begin with that.
If you are grouping by Service Code and placing the above formula in the footer you will only be computing {billing_tx_charge_detail.v_duration} for the last record in the group. If you are intending to use the formula and sum the results and place the results in the Service Code footer try the following. (basically remove the reference to group name)
If {billing_tx_charge_detail.v_SERVICE_CODE}) = "1530" then
ToNumber({billing_tx_charge_detail.v_duration})/3 else
ToNumber({billing_tx_charge_detail.v_duration})
You can use variables (num1) if you want to but they are not needed.
You can still use the second formula you referred to and place in the group footer OR you can place the first formula in details section, right click and insert a summary to the group footer. You can also place in the report footer if you need it to total there as well.

MS access latest date issue

I have 2 excel files at work where I maintain the rates of assets and the dates when the rates were issued. Another excel file has the list of assets and the dates when they were sold.
So one excel file has the following columns:
Asset------Rate------Rate_Issued_On
1. X-------1500------21-Apr-2014
2. X-------2000------28-Aug-2013
3. Z-------2200------11-Jan-2014
4. X-------3000------1-Jan-2014
The other excel file has (let's suppose):
Asset-----Sold_Date
1. X------1-Dec-2013
2. Z------12-Mar-2014
Now since the sold date of Asset X lies between 1-Jan-2014 and 28-Aug-2013 it should take the rate of 2000. If for example the sold date was 22-Apr-2014 it should take the rate as 1500. If the sold date is 27-Aug-2013 it should display a blank record. So basically the sold date should be greater than the latest Issued date and rate will correspond to that particular date.
I can easily get this working in excel but the problem is that the excel file has now become so large that it runs very slow. So I just want this incorporated in ms access. Is this possible? (I am a novice in ms access so kindly requesting you to go a little easy on me)
Thanks
Yes - a few simple queries can match up the data they way you want. If your two tables are called Rates and Sales, you could use two queries to get the results you need. The 1st query would use the Sales and Rates table to find the largest Rate_date that is less than the Sale_date, and the second query would match this back to the Rate table to get the rate on that date.
A very similar problem is described in How to use another table fields as a criteria for MS Access