I feel like what I am trying to achieve is simple. So I must be missing something rather basic.
My current expression:
Total Aged: Sum(CCur([Aged Debt Amount]))
This used to work fine. However, I now have some of my data with empty cells (NULL)
This is causing the expression to break. My thought was to add in an NZ but doesn't work. Am I putting the NZ in the right part of the expression?
Methods tried:
Total Aged: NZ(Sum(CCur([Aged Debt Amount])),0)
Total Aged: Sum(NZ(CCur([Aged Debt Amount]),0))
Total Aged: Sum(CCur(NZ([Aged Debt Amount],0)))
New method I have tried that didn't work:
sum(isnull([Aged Debt Amount],0))
Error Received:
Invalid use of Null
You shouldn't need CCur if the field is of data type Currency. Thus:
Total Aged: Sum(Nz([Aged Debt Amount],0))
Related
I'm working on a simple RDBMS project. My database contains work hours per day of each employee. I have to calculate work hours of complete month. It is not a problem. But I have a problem, here it goes, each workday field contains either number of work hours or it may contain text such as if the employee was absent (symbol "A") for a particular day or it may contain symbol ("H") for holiday etc. Now my task is to calculate the 30 day work hours and exclude any symbol. But obviously the approach I am using will get me "Data Type Mismatch Error." So any body got any solution or any suggestion please. Thanks in advance!
I tried to use sum formula with NZ function, it doesn't work. Also tried Query with the same error.
Use Val:
TrueHours: Val(Nz([YourHourTextFieldName]))
That will return 0 (zero) for non-numeric entries, and that allows you to sum the values.
I have Quotation form that has a calculated field that is for GST and is derived from labour and material totals on the same form. The calculation for GST works fine if there is data in both labour and materials fields but doesnt if there is nothing in the materials field as some of jobs do not require material.
GST =IIf(IsError(([txtLabourTotal]+[txtMaterialsTotal])*0.1),0,([txtLabourTotal]+[txtMaterialsTotal])*0.1)
The Expected calculation is to have the GST show an amount if there is no materials to calculate for. I have tried a number of ways to overcome this problem that all had the same result. Is there a way that I can overcome this?
Don't use IsError(), because NULL values are no error.
Use Nz() to map NULL values to zero:
=(Nz([txtLabourTotal], 0) + Nz([txtMaterialsTotal], 0)) * 0.1
should do it.
I have details figures like these:
Sales Amount
£285.00
£16,249.51
£345.68
But the total returned was:
£16,880.18
while I was expecting:
£16,880.19
This is supposed to be the sum of details but the last digit is being rounded. How do I overcome this limitation?
Since your round your detail in the second decimal digit you can use the following expression (change the field in the expression to match your own)
Sum( Round(Fields!val.Value,2))
Another option could be rounding your dataset in your SQL code
I'm working on a form that, after using a combobox (possible values are only EURO or USD), show the cost in the selected currency. Within my qry_costes I have all costs in local currency. I also have a second table RateToEUR with the conversion from several currencies to EURO, and a third one RateToUSD doing the same to USD. The idea is that, after using the combobox embedded in a form, field qry_costes.cost from qry_costes will be multiplied by the properly rate. I mean, if EURO is selected, and qry_costes.currency is BRL, for example, then qry_costes.cost will by multiplied by the value that belongs to BRL within RateToEUR. The problem is that I don't know how to distinguish between RateToEUR from RateToUSD. Is possible to use a IFF clause?
Thanks all for your help.
I've found that exRate table was wrong, but code is ok. Thanks anyway
I'm having difficulty with what seems to be a limitation in SSRS (BIDS) 2005, and upgrading to a newer version is not yet an option for me.
I have a DataSet that returns a bunch of payroll withholding data by employee, and I'm wanting to get the value of field "B" based on what I find in field "A." Specifically, I want to get a dollar amount based on a field "Code" being "OptlLife."
So, if Field A = "OptLife" give me the dollar value of Field B. Pretty simple, right?
The closest I can come is:
=IIF(First(Fields!Code.Value, "Withholdings") = "OptLife", First(Fields!AmtPct.Value, "Withholdings"), " ")
What's killing me is that "First" indicator. I don't want "first" or "last" or "max" or "sum." I want whatever row of data has the value OptLife. If I remove that indicator, I get a syntax error. How do I get around this?
What I really want is something like "select AmtPct from WithholdingsDataSet where Code = "OptLife" but it needs to be an SSRS expression.
EDIT PER IAN'S QUESTION:
So, I have a result set from the DataSet that looks like this.
Employee Code Method AmtPct
1121 401K A 400
1121 Roth null null
1121 FSAChild A 96.15
1121 FSAHealth A 192.31
1121 OptLife A 28.84
In my report, I have a textfield formatted for Currency, and need an expression that will pull the 28.84 into that field. Because I have multiple DataSets tied to this report, I need to specify which DataSet the value is coming from, hence the (Fields!Code.Value, "Withholdings") but that parenthetical statement has to be prepended with something. Nothing I put there gives me the value I need.
Once I nail this down, the same methodology will be used for distinguishing Roth and Traditional 401K, and FSA Childcare from FSA Healthcare.
You should be able to use something like:
=Sum(IIF(Fields!Code.Value = "OptLife", Fields!AmtPct.Value, Nothing), "Withholdings")
As you've seen, since you're referencing the data in a Textbox you need to use an aggregate expression.
The expression above will apply a Sum to the dataset, but will only consider OptLife rows, which seems to be what you're after. Assuming you only have one OptLife code in the Dataset, you'll only be considering that one row in the aggregate, which I think is what is required.