Calculate variance between 2 columns in ssrs - reporting-services

using ssrs, i have 2 fields in 2 columns which contain expressions. They calculate a percentage as follows:
FormatPercent(Fields!x.Value/Sum(Fields!x.Value))
and
FormatPercent(Fields!y.Value/Sum(Fields!y.Value))
I want a 3rd column which calulates the difference between these fields. How can I do this?
I cant use a calculated field to calculate the % for x and y as it uses an aggregate, hence I'm using expressions.
I don't want to add a 3rd expression which redoes the calculation for x and y as follows:
FormatPercent(Fields!x.Value/Sum(Fields!x.Value)) -
FormatPercent(Fields!y.Value/Sum(Fields!y.Value))
Any ideas?

Name the text boxes that present the 2 different values (txtXPercent and txtYpercent say)
Use the ReportItems collection to refer to these in the 3rd text box
Such as
=CInt(ReportItems!txtXPercent) - CInt(ReportItems!txtYpercent)

Related

Add total with different in percentage in SRSS Power BI report builder

I have a matrix with sales for district and store on the rows and different "time intelligence" on columns. I want to add totals. It works fine for values but for "YOY %" I don't want to sum the individual percentages of course - I want to have the total YOY for the values on the total row. How can I refer to these values? See the picture, the red value should be 109/77-1 = 42 % and not 183 %.
Any input is appreciated.
enter image description here
enter image description here
To answer my own question: I didn't figure out a way to referring to columns generated from calculation groups (is it even possible?) so instead I created all the measures (columns) as seperate columns in the dataset. Then I can easily refer to them like YOY %:
=( Sum(Fields!Actual.Value) - Sum(Fields!PY.Value) ) / Sum(Fields!PY.Value)
and the totals is shown correctly.

SSRS - add percentage of total?

I am just starting out in SSRS and have a dataset that looks like the below.
I have built this in a matrix table like so
I want to show what percentage each of the rows total is of the grand total, so for the attached image I would want to show what percentage 35 (counselling calls) is of 47 (total) and what percentage Legal calls (12) is of total (47)
I have tried =Fields!Calls.Value/sum(Fields!Calls.Value) but that just gives me 100% for both?
Would appreciate any help
You need to specify the scope of your SUM() expressions.
I'll briefly explain how scopes work and then get to the answer.
SSRS always evaluates an expression based on it's scope which is usually defined by the physical location of the expression within table/matrix. As you can see from your design all 4 textboxes show the same expression, [SUM(Calls}] which in fact is actually =SUM(Fields!Calls.Value). However they give different results because the scope of each is different. The first is in the category rowgroup and the month column group for example, the second one is in the category row group but in the total month group, and so on...
OK, now to the answer !
Assumming
your rowgroup is called 'CategoryGroup` (you will see the name in the rowgroup panel under the main designer)
your dataset is called DataSet1
You expression should be
=SUM(Fields!Calls.Value, "CategoryGroup") / SUM(Fields!Calls.Value, "DataSet1")
This basically reads..
Take the sum of the call column for all rows that are within the current CategoryRowgroup and divide by the sum of the call column across the whole dataset.
Notes
The scope names must be enclosed in quote and are case sensitive
The scope names must match either a row or column group, or a dataset name exactly.
the , "CategoryGroup" scope argument can probably be omitted as this should be the scope of the textbox anyway.

Calculate total by summing max numbers

I have a Matrix report that has two row groups and two column groups. There is column which has the calculation Max(Fields!AdjustedManning.Value) on the Row Group level as a subtotal. I want to add a total at the bottom which is outside of the row group to sum the subtotal numbers up. What expression can I use to do this? Effectively I'm looking to sum the max numbers
In the image the yellow box for design is where I need to put the expression and a preview of what I would expect it to calculate.
Design and Preview
You didn't show the rowgroup names so I'm guessing you have a rowgroup grouped by [WoLine] called Woline. Assuming this is correct then you should be able to use something like...
=SUM(MAX(Fields!AdjustedManning.Value, "WoLine"))
"WoLine" is the name of the rowgroup, you must include the quotes and it is case sensitive so adjust to suit your actual report.
What this does is get the MAX value within the "WoLine" rowgroup scope and then sum the results.

How to Display Only 1 Value Label in SSRS 2012 Calculated/Derived Series?

I have been using SSRS 2012 (Sql Server Reporting Services) with SQL Server Report Builder 3.0 (11.0.2100.60) to create Column charts that display columns for each day/week/month and display a trend line based on the mean across all days/weeks/months.
However, although the calculated series reflects only 1 value (the mean across all days/weeks/months), value labels appear on the chart displaying the single mean value for each day/week/month - that is, 3 days will result in 3 value labels for the same mean value.
Is there a way to force the series to show only 1 value for each mean trend line?
See below for sample chart.
The work-around I ultimately settled on involved creating duplicate series with value labels but invisible data points (obtained by setting Color to "No Color").
The values for this series are only assigned if the "dayofweek" field matches the first "dayofweek" field in the dataset, so only 1 data label will be displayed (namely, the first one).
For example, to show a single value for the average of the "physio" field for physiological alarms within my dataset ("techphysDayofWeek", I use the following formula):
=IIF(Fields!dayofweek.Value = First(Fields!dayofweek.Value,
"techphysDayofWeek"),Format(( Avg(Fields!physio.Value, "techphysDayofWeek") /
Parameters!StartDate.Value), "##.#"), "")
I wish SSRS provided an easier way, but after struggling with this seemingly simple issue for hours on end, I'm just glad to have any fix!
You can set the label text to be based on a formula. In that formula you could look at the value of the grouping field, and set the text to an empty string if it's not currently the group you want to have the label on.

Simple sum in a calculated control MS-access

Trying to get the sum of three fields and enter it in a fourth text box on the same report. For a particular report,
empnose =78
empright=555
empleft= 565
The total text box should be 1198
using the expression
=Sum([EmpNose] And [EmpRight] And [EmpLeft])
the result is -4
using the expression
=Sum([EmpNose]+[EmpLeft]+[EmpRight])
the result is 226514940
using the expression
=([EmpNose]+[EmpLeft]+[EmpRight])
the result is 78555565 (the three values concatenated)
What is the correct syntax?
If you want to add up the values of the current record only, Sum() is wrong, because it sums over all records.
=([EmpNose]+[EmpLeft]+[EmpRight])
should be correct. If it concatenates the values it seems your fields are text fields instead of numbers?
If you can't change the datatypes to numbers, you can try
=(Val([EmpNose]) + Val([EmpLeft]) + Val([EmpRight]))
The Val() function tries to convert a string to a number.