Is it possible to calculate total based on data in another cell? - ms-access

I want to count Total of Score based on the Grade. Example of table as below:
I want to do this in Access Report but not sure how to calculate it in Expression Builder. Please help.

Use expressions like:
=Abs(Sum([Grade-Math]="A"))
=Abs(Sum([Grade-Math]="B"))
=Abs(Sum([Grade-Science]="A"))
=Abs(Sum([Grade-Science]="B"))

Related

How to get Distinct Sum at SSRS Expression?

Please check the picture file attached. I want to get distinct sum of a column(Promotion Amount) based on another column(Promotion Name). At SSRS.
Cannot do this grouping sum at t-sql Level .. Need to be done in SSRS only.. through expression.
Thanks in Advance
Resolved. Grouped by "Promotion Name". Then Write Sum formula as SUM(Max(PromotionAmount,"GroupName"))

In SSRS, how do I compare a value of a parent report item with report items in a child group?

I am using SSRS 2008. I have 3 different groups above my report details that are calculated sums. I am trying to color the limit red if any of the invoice sums(A) in a child group is above the limit(B).
I am currently using this expression, but it is only looking at the first or last invoice amount. The limit report item is in a parent group just above the invoice's group.
=IIF(ReportItems!Invoice_DueDate.Value>ReportItems!Limit.Value,"Red","Black")
My Solution: I decided to use SQL to get the sum of the invoice amount grouped by due date. I then called that field in the parent group.
If I understand your question correctly, then I think you can use
=IIF(MAX(ReportItems!Invoice_DueDate.Value) > ReportItems!Limit.Value,"Red","Black")
You need some sort of aggregate function, such as MAX() to tell SSRS what the scope and operation of what should be done. (For example if you wanted to make sure the total didn't exceed the limit, you would use SUM(...)
You can reference parent groups from a child group using aggregate expressions specifying the parent group Scope.
For example, say we have some simple data:
And a simple table based on this, with a group based on grp.
Here the BackgroundColor property for the value textbox in the detail row is set as:
=IIf(Fields!value.Value > Min(Fields!limit.Value, "Group1")
, "Red"
, Nothing)
This checks all rows in the parent group of the current row, not just the current row. This works as expected:
Without knowing your data it's impossible to say if this will work in your case, but hopefully it gives you something to consider.
Edit after comments
OK, based on further comments it seems like you need aggregate on aggregate functionality.
This is available via SSRS expressions in 2008R2 and above only, so this won't help in your case.
For older versions, your best option might be to add an extra field to your Dataset that supplies the maximum Invoice value for each group, and then you can use this value without issues in the parent group.
There are some workarounds around that suggest using custom code to do this, such as this post, but I've never used this suggested solution and would only even consider it if you don't have any control over the report Dataset.

Order SSRS report column

I have a table in SSRS with a column which uses the expression
(Reportitems!Textbox71.Value / Reportitems!morCodeTextbox.Value)
This obviously divides one table filed by another and displays a percentage for each line.
I'm struggling to see how I can then order this percentage column to show the highest percentage in first row and then descending results. When I try and sort the table by going to table properties the available fields only include those from SQL query. Am getting errors when trying to use an expression to sort. Tells me that I can't use report items in sort expressions.
Does anybody know how I can achieve this?
you need to add a Sorting to table by expression: "(Reportitems!Textbox71.Value / Reportitems!morCodeTextbox.Value)"

Summing a field in an Access table and displaying the total

How do I sum a column in Access 2010 and display the total in a new column (using expression builder perhaps)?
It's generally a bad idea to store a calculated value in a table. If you need a calculated value, calculate it when you are displaying it. Generally this is done in a report or on a form.
There are exceptions to this, but it sounds like you would be best served by displaying the calculated field in a report/form and not in your table.
SELECT SUM(num_fld) as Sum_Nums
FROM your_table
WHERE num_fld > 5;
I don't know about expression builder but this query works

How to I get cumulative monthly subtotals in SSRS?

I'm using SSRS to create a report which shows a lot of transactions according to a trade date. I've made a group on the month and year called 'grpMonthYear'. Inside that group I've made a subgroup on 'TradeDate'.
The groups and all work perfectly. I'm also generating monthly subtotals in the footer of the group 'grpMonthYear'.
But now I want the cumulative subtotals.
Example, if Jan'13 totaled up to $5,000.00 and transactions in Feb'13 totaled up to $7,000.00 So the monthly subtotal in Feb'13 should show me $12,000.00
I tried using
RunningValue(Fieldname,SUM,'grpMonthYear')
But it doesn't work.
Am I missing out something?
You need to set the scope in the RunningValue function to one outside the current group, for example the table's DataSet itself.
So something like:
RunningValue(Fieldname,SUM,"DataSet")
Here's a simple example based on the following data:
I've created a simple report grouped by grpMonthYear:
The Month Total is just the sum in the current group scope.
The Cumulative Total expression is the following:
=RunningValue(Fields!tradePrice.Value, SUM , "Trades")
Where Trades is the DataSet name. This now gives the required results:
So hopefully this helps - just keep the ordering of all the elements of the table in mind as well as the specific parent scope to use if there are nested groups.