I am trying to build an SSRS report that has a column based on a percentage:
AgentSales AgentCommission Commission
20 .25 5
33 .12 3.96
46 .76 34.96
Totals: 99 [Unknown Calculation]
However, where I am having problems is I need to get what would be the totals column? How would I calculate the Commission so that the number shown in [Unknown Calculation] to display what I assume would be the average commission?
Commission column is simply AgentSales * AgentCommission. The total commission wouldn't be a SUM(Commission), but would more or less be the average commission for all agents.
Assuming you want to calculate the weighted average commission then I would calculate it like this..
Expression 1: is simple as per your sample.
=Fields!AgentSales.Value * Fields!AgentCommission.Value
Expression 2: is the sum of the results of expression 1
=SUM(Fields!AgentSales.Value * Fields!AgentCommission.Value)
Expression 3: is the expression 2 divided by the sum of agent sales
=(SUM(Fields!AgentSales.Value * Fields!AgentCommission.Value))
/
SUM(Fields!AgentSales.Value)
The other cells should be self explanatory...
When we run the report we get the following.
If this is not what you wanted, then please edit your question to show the desired result and how you arrived at that result.
EDIT AFTER UPDATE FROM OP
If you want the cell marked "2" in my sample to be an average of the values above then simpley change it to
=AVG(Fields!AgentSales.Value * Fields!AgentCommission.Value)
Related
Approach 1:How to take % value for Line graph for series Groups?
I am setting up a ssrs report like with x axis(Category Group) as Finished Week, QualityPercent( as Series groups-RFT%,REwork%,Scrap%) and Values as Sum of Quantity.
In the above graph the quatities are shown in percentages based upon weeks(the actual result whose plot values are given at left side of image). Respective tables structure:
But I am getting the chart like this
Here the y axis is not plotting well asper the category values, sometimes shoots upto 250%!! or 1400% !!! (this is embarrassing).
For the above graph i used expression as:
IIF(Sum(Fields!QTY.Value,"Chart11_SeriesGroup"),Sum(Fields!QTY.Value)/Sum(Fields!QTY.Value, "DataSet_Production"),0)
What i am missing? I even used #Percent. Kindly help me.
Approach 2: How to plot the ssrs graph using below result from sql query?
FinishedWeek QualityPercent QTY Percentage
1 Rework (%) 844 0.109724
1 RFT (%) 6811 0.885465
1 Scrap (%) 37 0.004810
2 Rework (%) 742 0.094618
2 RFT (%) 7096 0.904871
2 Scrap (%) 4 0.000510
After much work done with second approach, I wrote the separate query for the above table
asper the link:
Calculating percentage within a group
select t1.FinishedWeek,t1.QualityPercent,Sum(QTY) as QTY,Sum(QTY)/ t2.TOTAL_QTY as Percentage from #temp
AS t1
JOIN (
select FinishedWeek,Sum(QTY) as TOTAL_QTY from #temp
group by FinishedWeek
) AS t2
ON t1.FinishedWeek= t2.FinishedWeek
group by t1.FinishedWeek,QualityPercent,t2.TOTAL_QTY
From above query , took the Finished Week as Category, QTY as Values, and QualityPercent as Series Groups
I have to do a query that shows training completion dates for all employees. The end result would be the number of employees that attended company trainings each quarter.
I have setup the query to have the user enter a start and end date for it (example 1/1/17 - 3/31/17) which works and a total row which also works. The issue I am having is I only want the count to include the records that fall within that range.
EXAMPLE
Employee Name Training1 Training2 Training3 Training4
Noname 07/06/17 1/12/17 2/15/17 6/6/17
COUNT 1 1 1 1
I know the query above is right because 2 pieces of the record fit the puzzle however, 2 pieces do not. How can I make my query work to only count what fits in the given date range? So COUNT should be 0, 1, 1, 0?
Simple Q:
In SSRS 2012: require a matrix with column totals derived from the dynamic column headings;
e.g.
Period 1 2 3 Total Total
Type Act Bud Act Bud Act Bud Act Bud
Total 10 9 10 9 10 9 30 27
is this possible in SSRS?
Can easily get the total of the sum of columns -(57) but not split by type.
Thank You.
data is grouped ;
Business Unit - Row Group
Account Type - Row Group
Month Period - Column Group
Amount_Type (Act, Bud) - Column Group
The Aggregate is Amount
Tks
Without knowing the structure of your dataset I think you can add two columns outside the columns groups at the right side and use these expression to calculate the respective total:
For Actual total:
=SUM(IIF(Fields!Type.Value = "Act",Fields!Amount.Value,0))
For Budget total:
=SUM(IIF(Fields!Type.Value = "Bud",Fields!Amount.Value,0))
UPDATE: Try setting the scope of the SUM function.
=SUM(IIF(Fields!Type.Value = "Act",Fields!Amount.Value,0),"DataSetName")
Replace DataSetName by the actual name of your dataset.
Let me know if this helps.
I have this table with a column named Open_Time which contain a datetime value. I would like to have another column named Total Ticket In June with the total count of ticket in June, so I've inserted the expression like below:
=Count((IIF(DatePart("m",Fields!Open_Time.Value,0,0) = "6",1,0)))
but there seems to be an error. To make myself clear, the table should look like this:
Assigned Name Ticket ID Open_Time Total Ticket in June
Ivan 001 3/28/2014 2
002 6/24/2014
003 6/11/2014
I would like to get value "2", which is the total number of ticket in June. Any idea? :)
You need to switch to a Sum aggregate instead of Count (based on your IIF, Count will count every row instead of giving you a total number of occurences):
=Sum(IIF(DatePart("m",Fields!Open_Time.Value,0,0) = 6, 1, 0))
From your table it's hard to tell your row groupings, but keep in mind that you'll only get the sum you expect if that expression is on a totals row (i.e. if you use that expression on the detail row it will simply list 1 or 0 for each date).
Try this:
=Count((IIF(DatePart(dateinterval.Month,Fields!Open_Time.Value,0,0) = 6,1,0)))
I have to get distinct rows sum in SSRS expression.
**StudentId TestScoreMath CurriculumEnrolled EnrollStatus**
100 200 Nursing Enrolled
100 200 Physical Enrolled
200 100 Tech Enrolled
Total Student TestScoreMath should be 300 not 400. I tried using the expression
=Sum(Fields!TestScoreMath .Value, "table1_Group3")
How can I SUM the value of TestScore of distinct students? I need this only in SSRS.
In SSRS 2005, this is not too easy. I would add embedded code to keep a running total. You can have the custom code to check to see if the current student ID matches the last. If so, then don't add another test score to the total. Or you could group by Student ID and call your custom code only in the header or footer of that group.
This sample shows totaling all rows: you'll need to add to this to track the studentID.