How can I sum a column of $90 then $20 without removing the dollar sign in access query criteria - ms-access-2007

It gives me error that data type mismatch in criteria expression , but can sum it without removing the dollar sign

The $ sign is for display only. The values are truly numerics.
So, sum, add, or filter as for other numbers, and then apply the format, Currency, where you wish to display the totals.

Related

IIF statement is showing a 0 where I know there is a value

I have a dataset with values that I'm am trying to put into an SSRS report. Here is some example data:
Fund#
last week amount
YTD Total
1
$100
$1500
2
$0
$300
3
$500
$500
4
$0
$0
The first column in my SSRS report is a fixed list of fund names in the certain order that I want them to appear and I want to insert the amounts from the dataset into the row with the corresponding fund name and into the right column.
I tried to get the amount for Fund 1 from last week ($100) to appear in the report using the following expression:
=iif(Fields!fund_no.Value=1,fields!last_wk_amt.Value,0)
However, this is returning a 0 value but I know it should read 100. This seems pretty simple, but I just can't figure it out what I'm doing wrong.
Thanks for the help.
It sounds like your field is an aggregate of the dataset. The IIF statement works on a ROW basis. In your expression, it finds the first row (which is apparently not 1) and returns the evaluation.
I believe it would work correctly if you SUM the IIF:
=SUM(IIF(Fields!fund_no.Value = 1, Fields!last_wk_amt.Value, 0))
If your AMT field is not a decimal value, you'd need to convert the zero to a decimal to avoid an error about aggregating mixed data types:
=SUM(IIF(Fields!fund_no.Value = 1, Fields!last_wk_amt.Value, CDEC(0)))

How to multiply all values in one column to make one number?

In SQL Server, I am trying to multiply all values of a calculated column in a table in descending date order, to produce one number.
This is so I can calculate a factor that can be applied to a different table / value, i.e. multiplying every value in the "price rate" column to produce a "price factor"
So far I have been trying to use exp AND log functions with no luck.
There’s no PRODUCT() or MULTIPLY() aggregate function in SQL because it’s so likely to overflow. However, as you were trying to do, this can be done with LOG and EXP,
SELECT EXP(SUM(LOG(price_rate))) as price_factor
FROM yourTable
Note that using LOG/EXP like this with integer values will not usually produce exact integer results.
In absence of an aggregate "product" function in SQL, one method uses arithmetic: you can sum the logarithm of each value, then take the the exponential of the result.
select exp(sum(ln(price_rate))) as price_factor
from mytable
FOr this to work properly, all values of price_rate must be greater than 0.

Formatting Number Field to Currency Using TO_CHAR returning hash characters

I am running a simple sum and conversion to currency on a NUMBER field in an Oracle database.
My query is:
select
TO_CHAR(eve.data_entry_date, 'yyyy-mm'), wtc.description as WORK_TYPE,
TO_CHAR(sum(sev.amount),'$999,999.99') AS "Total Invoice Amount"
from
EVENT eve,
SOW_EVENT sev,
WORK_TYPE_CODE wtc,
SOW_WORK_TYPE_XREF swt,
WORK_TYPE_ITEM_CODE wti
where
eve.event_number_id = sev.event_number_id
and sev.WORK_TYPE_CODE = WORK_TYPE_CODE
and sev.event_number_id = swt.event_number_id
group by
TO_CHAR(eve.data_entry_date, 'yyyy-mm'), wtc.description
The query runs successfully, however the amounts showing up in the "Total Invoice Amount" column are returning hashes like:
Year-Month WORK_TYPE Total Invoice AMount
2019-01 Physical Work ############
2019-01 Technical Work ############
I had thought I just needed to resize the column, but that didn't work. When I just run:
sum(sev.amount)
it populates the amounts, just not formatted as currency as the 'amount' column is a number column. Any idea why I am getting the hashes when I format to currency?
From the documentation:
All number format models cause the number to be rounded to the specified number of significant digits. If a value has more significant digits to the left of the decimal place than are specified in the format, then pound signs (#) replace the value. This event typically occurs when you are using TO_CHAR with a restrictive number format string, causing a rounding operation.
Your format mask needs enough digit placeholders for the highest value you expect to see. At the moment the values seem to be above a million.

Access 2007 SQL SUM() is adding negative dollar amount in query

When I'm running a query to give me a sum of the dollar amount the negative dollar amount is getting added to the total sum. However, when I just use the total sum funtion in Access it gives me the correct sum.
SELECT SUM(VstoreTotal) AS NetSales
FROM [Store Reactive Matches All Cust]
WHERE VstoreTotal>0;
Ex. $250.00
$100.00
$0.00
($100.00)
Gives me $450.00
However, when I just use the total sum funtion in Access it gives me the correct sum.
Gives me $350.00

summing up only certain values in column based on name in ssrs reports

By default, the SUM - sums up all the column values. But in my case, i am having a report which is grouped by Name. A name can have single offer with multiple start date's. So, a report has to display each entry for all different start date i.e Same name, offer, players only difference is the date. So for ex, when you sum up the players, only one entry per name needs to taken into account. Because, even though it has multiple start date, other entries are same and duplicated.
The expected result should be like,
The offer cost $10 refers to same $10, so it should be added only once. Similarly for players, etc., But i need the display as shown above, each entries should be shown.
How to solve this?
If all you want to do is avoid aggregating the value in the group total row, as in your example, just remove the aggregation from the expression, i.e. change:
=Sum(Fields!Players.Value)
to:
=Fields!Players.Value
This just returns the first Players value in the Scope - since it's the same value for every row this should be fine.
If you need to further aggregate this value to something like a grand total row, you have a couple of options.
For 2008R2 and above, you can use nested aggregates as an expression in the report - something like:
=Sum(Max(Fields!Players.Value,"MyGroup"))
For 2008 and below, you will need to add the aggregate value to each row in the Dataset and use this without aggregation in the report as required.
I haven’t worked with SSRS much but if this was a regular SQL query you would have to group by date range.
Try adding start date column and check if you can add another group by on top of what you already have.
It would be useful if you can provide more details here like table schema you use for retrieving the data.