Ms Access : Math Functions with a report - ms-access

I have a report in access which displays the number of times a certain procedure is a done as well as a break down of the scores received, which can either be "N" "B" or "C"
I want to include in my report the % of procedures that are deemed below standard. These are the scores and of N and B combined.
I have written the following to work this out
=([B]+[N])/[Total Of Entry ID]*100
The problem occurs if either N or B do not have a value which is possible then it does not calculate the percentage. Is there a way I can tell it that if there is no value to assume the value is zero?
Thanks in advance.

You can use the Nz() function to apply a substitute if the field is null;
=(Nz([B], 0) + Nz([N], 0))/ ...

Related

How to get group total inside a row in a rdl report?

How do I get the total of the group inside a row item?
I have tried Fields!Sales.Value/SUM(Fields!Sales.Value) but it returns 1 instead of the row_amount/group_total the report returns row_amount/row_amount
PS: Data comes from a SSAS cube. I made picture bellow1 to summarize what I wanna do
You could potentially just compare the values by the ReportItems. That is, you can specify a name for the sales textbox and for the totalsales textbox and do the comparison using those values. The following expression would likely work as intended.
= (ReportItems!SalesTextbox.Value / ReportItems!SalesTotalTextbox.Value) * 100.0
The other thing to consider with this is that if your result is 1, you may be dealing with integer division from your data. Make sure the data being returned is coming in with a double or decimal datatype, not an integer. It may work as you have it currently if you get the datatype corrected.
You also need to handle "divide by Zero' errors. Using an "=IIf (denominator = 0, 0, numerator/denominator) doesn't work since an "IIf" function evaluates both the "then" and the "else" and will still return an error. We use a bit of custom code that I found on SO (I wish I could remember where it came from so I could give credit where it's due).
Public Function HandleDivideByZero(ByVal numerator As Decimal, denominator As Decimal) As Decimal
If denominator = 0 Then
Return 0
Else
Return numerator / denominator
End If
End Function

Access 2013 Count

I am working on a report in Access 2013 I need to seperate the first 20 records in a column that contain a value and assign a name to them. Such as at 1-20 I need it to insert Lot 1 at 21-40 need to assign Lot 2 etc... The report needs to be separated by lots of 20. I can also just insert a line when it reaches sets of 20 without a name if that makes it easier. Just need something to show a break at sets of 20.
Example: As you can see the report is separated by welder stencil. When the count in the VT column reaches 20 I need to enter a line or some type of divider to separate data. What our client is asking for is we separate the VT in sets of 20. I don't know whats the easiest way to accomplish this. I have researched it but haven't found anything.
Example Report with Divisions
Update the report's RecordSource query by adding "Lot" values for each row. There are multiple ways of doing this, but the easiest will be if your records already have a sequential, continuous numerical key. If they do not have such a key, you can research generating such sequential numbers for your query, but it is beyond the scope of this question and no details about the actual data schema were supplied in the question.
Let's imagine that you have such a key column [Seq]. You use the modulo (mod) and/or integer division operators (\ - backslash) to determine values that are exactly divisible by 20, e.g. ([Seq] - 1) mod 20 == 0.
Generate a lot value for each row. An example SQL snippet: SELECT ("Lot " & (([Seq] - 1) \ 20)) As LotNumber ...
Utilize Access report sorting and grouping features --grouping on the new Lot field-- to print a line and/or label at the start of each group. You can also have the report start a new page at the beginning or end of such a group.
The details about grouping can be found elsewhere in tutorials and Access documentation and are beyond the scope of this question.

How can I specify an integer's total number of digits in VBScript?

I have a "text field" in SSRS in Visual Studio 2008 that I would like to convert to a number in order for the export to Excel to work. Simply changing the properties to Number does not work. So I've decided to try to write some code in the Value field for it to work.
I have an invoice number that must always have seven digits, e.g. 1938576, 0000001. Using CInt(Fields!Invoice.Value) does not work as it does not keep any leading zeroes. How can I convert this field to a numerical value (integer for this one, but I have a couple other fields that it must work with doubles) while also determining exactly how many digits must be shown? Something like CInt(Fields!Invoice.Value, 7) would be great, but I don't think that parameter is part of the function.
VBScript doesn't have any number formatting functions that will work for this. You have to write your own.
Function PadNumber(x, digit_count)
If Len(x) < digit_count Then
PadNumber = String(digit_count - Len(x), "0") & x
Else
PadNumber = x
End If
End Function

SSRS Conditional Summing

I have an SSRS report that displays several pages of rows. In each row is a "TYPE" field. In that TYPE field there is either an "M" for the value or a "P" for the value. At the end of the report I want to summ up all the price values for the "P" TYPES. I tried this but it prioduced an #Error:
=Sum(iif(Fields!TYPE.Value = "P",Fields!EXT_QTY.Value * Fields!PRICE.Value ,0))
this summed all rows
=iif(Fields!PART_TYPE.Value = "P" , Sum(Fields!EXT_QTY.Value * Fields!PRICE.Value ), 0 )
I'm sure this is do-able. Any ideas? Thanks
Found the answer....
=SUM(IIF(Fields!PART_TYPE.Value ="P",CDbl(Fields!EXT_QTY.Value * Fields!PRICE.Value), CDbl(0.0)))
The SUM fails due to type comparison - you can't Sum values of different types, being the expression (probably a Double) with 0, an Integer. MikeTWebb's answer does explicit type conversion to get around this error. This is fine for this specific example, being a Sum, however this doesn't produce an accurate result if you want an average (being Sum / Count) of the values where the Type is P. That is because 0 is a value and would be included in the averaging calculation when you actually want those values excluded from the calculation.
Another option is to use Nothing instead of 0:
=Sum(IIF(Fields!TYPE.Value = "P", Fields!EXT_QTY.Value * Fields!PRICE.Value, Nothing))
This solves the type comparison error without needing explicit typecasting and is a better solution when you are using aggregations where whether the value exists or not is significant to the result, like Average.

SSRS 2005 Matrix Reports - Editing Total

This seems as though it should be simple, but appears not to be.
In SSRS 2005 I've written a matrix report and added some fields, one of which has the formula: If (x / y >= n, 1, 0). I've called this field 'Accuracy'. The report aggregates this field across a number of individuals and then for a number of days.
Ideally I want a subtotal that gives a sum of the 'Accuracy' figures (so we can say we had n people who were accurate today). However, the subtotal calculates the formula for the totals of x and y. Subtotals is only ever going to be 1 or 0.
Any ideas as to how I can get a Count of Accuracy displayed on the matrix report? I've tried creating various fields along the lines of Sum(accuracy) and Count(accuracy) - these return an error when the report is run.
Thanks!
maybe report behaves 0 and 1 as a boolean value. you can make a dll that do this work for you and reference to your report and use the methods that exist for this work in dll.
Try using the running value. You could put the expression inside it or inside the report code block and just call it.
=RunningValue(what to count, sum, scope)
=RunningValue(Fields!Cost.Value, Sum, Nothing)
More info here:
http://msdn.microsoft.com/en-us/library/ms159136.aspx
Hope it helps.