Summing columns in access reports based on other column's text - ms-access

so I'm using Microsoft access reports and I need to be able to sum only the rows in a column that are designated in a separate column by text. So column A has either a Y or N for every row and I need to sum the numbers in column B that have a Y in column A.
I just don't know how to designate which numbers should be summed using the other column.
Thanks

IIF(A='Y',Sum([B]/[B Grand Total Sum]), 0)
Wouldn't you want to evaluate the A criteria before you SUM anything up?
Honestly in this case I don't think it matters, but in general you will want to do evaluations of criteria before you do any aggregations or you're inevitably decreasing your performance. Also, your results may be inaccurate if you do IIF evaluations of columns outside of the summation.

Sum(Iif([A]="Y",[B],0))/SUM([B]) Should do the trick.
This will add B if A = Y and 0 if A <> Y, then divide that SUM by The overall total of Column B.
You could also do this in the underlying query...

Related

SSRS: Group by matching a pattern

How can I group by based on a pattern in column to calculate the total?
My table has the following columns: CustomerAccount (char30), AccountDesc varchar(200), AccountAmount1 (decimal), AccountAmount2,....., AccountAmount5.
The CustomerAccount is in this format: xxx.xxxx.xxxxx.
Some of the values are:
How do I group the data so any value like xxx.xxxx.31xxx, xxx.xxxx.32xxx, etc is grouped together so I can calculate the AccountAmount like the image below in SSRS report? The highlighted part ranges from 30 to 39:
I am not sure if it would be easier to do it in SQL query, but not sure how.
If your account number is always a fixed length (or more precisely, if the numbers you want to group by are always in the same position) then you can create a row group with the group expression being something like
=MID(Fields!CustomerAccount.Value, 11,2)
If you wanted to group an everything up to that point you could do
=LEFT(Fields!CustomerAccount.Value, 13)
The numbers might be out by one as I can't remember if these are zero or 1 based functions but you'll soon notice that.

SSRS Sum Amounts with different columns based on an expression

So i am trying to sum columns based on a condition from one group to another.
The first column is the expression that counts how many Meters are in that group by company.
in the photo it shows eight by that company that have a value of meter,
Then to the right is invoice amount
What i need to do is a conditional format for the expression that says if x company has 8 meters what is the total amount for all invoices that = meter.
I have tried a few ways but unable to get the count out of the expression under the column so i know it has something to do with my condition statement and not sure wher it is going wrong any help would be appreciated
=Sum(IIf(Fields!invoiceclass.Value = "METER" and Fields!companyname.Value, Fields!invoiceamount.Value , Nothing), "AR")
Try using:
=Sum(IIf(Fields!invoiceclass.Value = "METER", Fields!invoiceamount.Value,0))
I think you don't need to specify a scope since you want the sum be calculated per instance in the company group and you are using the expression in a cell inside the Company group scope.
Let me know if this helps.

SSRS adding a percentage column based on a specifc column category in a matrix/tablix

I have a matrix/tablix set up so there are 4 row groups going down the left-hand side and a column group called RegCompCategory:
When the report is run, the RegCompCategory column group produces 3 distinct columns based on the categories in the underlying data:
What I'd like to do is add another column before the RegCompCategory column group that will display a percentage of the "fully-marked" column against the "total" column:
I'm guessing I will need to write an expression for the fields highlighted above, but I'm not sure how to reference the RegCompCategory to identify specifically the "Fully-Marked" category of data.
Could someone give me a few pointers? Many thanks.
Try:
=Count(IIF(Fields!RegCompCategory.Value="Fully-Market",Fields!RegCompCategory.Value,Nothing))
/
Count(Fields!RegCompCategory.Value)
It will count the number of Fully-Market rows and divide by the total rows. I think that is what you are expecting.
Let me know if this helps you.

How to get overall total in row group

I have a row group in SSRS that calculates totals by each group. However, I would like to get the percentage of each group out of the overall total. However, I do not know how to achieve getting the overall total to work within the same expression.
Right now I have this to get my total of each group:
=Sum(Iif(IsNothing(Fields!ID.Value),0,Iif(Fields!STATUS.Value = "Closed",1,0)))
But I am not sure how to divide that by the overall total. Would anyone have any ideas?
You will need to apply the same expression, but in a different Scope.
e.g. to get the total for the whole Dataset, you will need something like:
=Sum(Iif(IsNothing(Fields!ID.Value),0,Iif(Fields!STATUS.Value = "Closed",1,0)), "DataSet1")
Where DataSet1 is the name of the Dataset used by the Table.
Once you have this new expression, simply divide the Row total expression by the Dataset total expression to get the percentage.

SSRS IIF expression for Counting Division

Hi I am trying to write an expression of COunt Division based on price as shown in figure http://i43.tinypic.com/2r47hqx.png
I am doing group column on Division but how can I get exact no. of count in Count Division Column those having price in their division.
Can anybody suggest any 'expression' that I can use in that Count Division Coulmn.
Please help!!!
As you say you have a column called Division that you are grouping on, add a summary column, i.e. outside of the column group, and set the textbox expression to:
=CountDistinct(Fields!Division.Value)
This will be applied in the row scope only so will effectively be a count of all non-null divisions in that row.