I have a tablix in SSRS that has a column that contains BOTH positive and negative numbers. Any time there is a negative number in the column I get an #ERROR when using the SUM() function.
Related
I'm having an issue in my SSRS report. What I'm trying to accomplish is get a correct summary total for a particular group, on field ClaimNumber
How the particular formula works is based on other fields in the record, and on of those values being zero:
=iif(Fields!FieldA.Value=0,0,Fields!FieldA.Value-Fields!FieldB.Value-Fields!FieldC.Value)
So if FieldA is zero, the displayed value is 0, otherwise it displays FieldA-FieldB-FieldC.
This works fine for each individual lineitem, but the summary totals on the grouping on ClaimNumber are incorrect, as in some cases the FieldA value under that particular ClaimNumber is 0, sometimes not. So I'm having trouble summing on the ClaimNumber grouping total, as the summary does not know which records FieldA is 0, and which are not.
There must be an SSRS custom code formula that would work in this situation?
If you wrap a Sum function around your expression, or even around each individual column in the expression, it's only going to evaluate that once. In other words, this describes the issue you're having where it's not accounting for some of the rows having 0 in FieldA. One way to correct this is to make your expression a calculated field on your dataset. Then you can Aggregate the calculated field to get totals and subtotals. Since it is a calculated field, it will be evaluated row by row to get the correct total. So the good news is: no custom code!
I am trying to calculate the average of six machines in the following table.
The first column represents the machines, the second column is the good pieces and the third column is performance.
In the last row I want to calculate the average (the mean) of the rows but the result is not correct here. It should be 33,6%.
This is the expression I used:
=iif(AVG(Fields!Oee.Value)=0, "-", AVG(Fields!Oee.Value))
How can I calculate this without zeros?
For the calculation you need to divide the sum of the column with the count of non zero rows
= SUM(Fields!Fields!Oee.Value)/ SUM(Iif(Fields!Fields!Oee.Value=0,0,1))
Also if you want to output something else for zero values you can use formatting eg. 0,0;-0,0;"-" (first part is for positive numbers, second for negative and third for zero)
I found this solution:
I used the filter option:
But now in the tablix you can see only the machines which run.
I have a report. This reports returns a lot of rows. One of the columns is qty_req (quantity required). I need to AVG() this column and put the value of the average at the bottom of the report. The problem is that sometimes some rows have a zero in this column. I want the average to exclude any rows where there is a zero. How can I accomplish this?
What I've tried: I tried using DAvg in the query but it made the query time enormous.
Avg() ignores Null values. So you can use an IIf() expression to swap Null for your zero values, and then base the Avg() on that IIf() expression.
Here is the Control Source for a text box in my report's footer:
=Avg(IIf([gainOrLoss]=0, Null, [gainOrLoss]))
gainOrLoss is a field in the report's Record Source. And the text box displays the average of all those values which are neither zero nor Null.
Well then you can't use a calculated SUM() or AVG() field, simple as that.
These functions always use all rows in the report.
You need DSum() or DAvg() to calculate it separately.
If that's too slow, you need to tackle this problem.
I have a table in SSRS 2008R2 that calculates a percent value for two numbers, and places an asterisk (*) in the last column if the percent value is below .65. This works fine in the individual rows. However, I have to calculate the percent value for totals rows as the table is rendered (1st row, Percent column). I need to use this value to determine whether the asterisk in the '<65%' column will show. Can this be done, or do I need to go back into the code and derive the value there?
The answer to your question depends on whether the calculated cells are inside the scope of the group on which you are aggregating. If they are inside the group scope, it is possible to derive these values in SSRS. If not, they have to be pre-calculated in the underlying dataset. This is because referencing of cells cannot be determined when a source cell's position relative to the derived cell is dynamically generated.
I wanted to figure out a way to get the percentage by using the data divided by the sum of the overall data.
For example:
[NumberofClients]/[Sum(NumberofClients)]
For each row it should have a different percentage based on the number of clients.
However, when I execute the expression above I always get 100%.
When you're apply the Sum, it will be calculated in the current Scope - if this expression is in a Details row, it will only ever be looking at one row, which explains why it's always 100%.
You need to use a Scope parameter to get more than the current row in the Sum, something like:
=Fields!NumberofClients.Value / Sum(Fields!NumberofClients.Value, "MyDataset")
Which is giving the % value for the particular row compared to all the rows in the Dataset, which seems to be what you're after.
You can change the Scope parameter to be a group instead of the whole Dataset as required.