Is it possible to sum the expression column in SSRS - sql-server-2008-r2

I am stuck in a scenario where client needed to do sum of column which is containing calculated values(Expressions) which are calculated at the run-time (At the time of generating report).
I suggested client to calculate this column at database side and return this column to SSRS dataset but due to some circumstances it is not possible.
Any help on this will be greatly appreciated.
Thank You

I don't have comment access So Iam not able to ask you more details. You can SUM up the calculated expression in SSRS AS you didn't mention how it looks.I am getting one example.
If this is how your normal cell of calculation looks,
=Fields!FirstCol.Value+Fields!SecondCol.Value
Then the SUM can be
=SUM(Fields!FirstCol.Value)+SUM(Fields!SecondCol.Value)
And if you added the calulatedColumn in the Dataset itself then it becomes more simple as you just have to do as,
=SUM(Fields!CalculatedCol.Value)

Related

Tableau calculated field that refers to its own previous lagged (-1) value to calculate

I need help on a basic calculation that I'm unable to figure on Tableau.
I am trying to setup a calculated field that has dependency on its previous value to calculate its current value. Here is a simple example from Excel -
Sample Exhibit
As you can see, each value in a row is dependent on its previous value and multiplied by a constant.
In Tableau, when I'm trying to create a calculated field, it is not letting me refer to itself (-1 lagged value) in the code. I'd appreciate any help on how this can be resolved. Thanks in advance!
Tableau can do this client side with a table calc. You’ll have to learn how table calcs operate from the help- especially partitioning and addressing. Then you can use the function Previous_Value() to refer to the previous value. Practice on something simple first to make sure you understand how previous value() works. Hint, the argument to that function doesn’t mean what most people assume it means
If you want to perform this calculation server side instead, then you’ll need to use custom SQL so you can specify an analytic aka windowing query
Check the LOOKUP field to get the value from the preceding row. For example: LOOKUP(SUM([Value]),-1)
https://help.tableau.com/current/pro/desktop/en-us/functions_functions_tablecalculation.htm#lookupexpression-offset
You may need to make yourself familiar with the Table Calculation partitioning if not getting the expected result.

column wise addition in tableau worksheet

I have made this tableau Worksheet. All columns are derived using calculated field. Based on resource I am calculating all attributes.
Please help me to add all values column wise in same worksheet .
I tried using "total" available in analytics pane but its not working in this case .
Thanks and Regards
The way this is set up, which each column being a calculated field, to sum them also requires a calculated field.
[ColumnA]+[ColumnB]+[ColumnC]+etc
Adding Totals to the table won't work in this case, as you have discovered.

SSRS Aggreation on Calculated Field

I am trying to perform an aggregation on a calculated Field in SSRS and am getting the following error:
[rsAggregateReportItemInBody] The Value expression for the textrun 'Textbox43.Paragraphs[0].TextRuns[0]' uses an aggregate function on a report item. Aggregate functions can be used only on report items contained in page headers and footers
This is the formula I tried to use:
=Sum(ReportItems!PlanPurchPrice.Value, "Select_UCPUtilization")
In this Case PlanPurcPrice is also an Expression:
=First(Fields!PawPlanPurchPrice.Value, "Select_UCPUtilization")
Any suggestions on this would be greatly appreciated.
SSRS 2008 does not support the functionality you are looking for unless the report item is located in the header or footer (as is stated in the error message). I would, instead, propose two alternate solutions:
First Option
Place the calculation in your query (if possible) at which point you can then reference the field and the aggregate will work as desired.
Second Option
You essentially want to create the aggregate you're looking to return elsewhere in the report where it is directly connected to the Select_UCPUtilization scope, then reference the aggregated value elsewhere. Follow these steps:
Within the same scope as report item PlanPurchPrice, calculate a sum of the PlanPurchPrice. Name the textbox containing the aggregate something meaningful (e.g., Sum_PlanPurchPrice).
Reference that textbox directly wherever you were trying to use the ReportItems sum before (i.e., =ReportItems!Sum_PlanPurchPrice.Value)
Hide the workaround. Place the aggregate you created in an additional column or row attached to the Select_UCPUtilization scope. Turn the text white, turn off growth and shrinkage, and make the row very tiny (a pixel or two high).
Using the second option, the report item does exist (and is visible, which is important) on the report and contains the sum you are looking to return elsewhere.
Hope this helps. if this doesn't make sense, please reply via comment and I'll help you to the best of my ability.

Sparkline based on Expression using custom code

I have an SSRS report which is reporting sales grouped by Month. One of the columns in this report is a calculated fields which takes 2 values and passes them to a custom code routine that is defined for this report. The textbox that is populated with the following code:
=Code.DivideBy(ReportItems!textbox21.Value, ReportItems!EarnedIncome1.Value)
All this Custom Code does is to divide the First Parameter by the Second Parameter (in this case whatever is in textbox21/EarnedIncome). The response is them shown on the screen as a percentage.
Below is an example of the report:
1 http://www.propelpos.com/images/screenshot002.jpg
This worked great. What we are trying to do now is to graphy the % that is in the BDX Loss ratio column which is figured out by the formula above (dividing Losses by Earned Premium)
When I try to copy the expression in the chart data and set the Category Groups to PeriodYearMonth (same as all the others), then I get a straight line.
I have no idea where to go next. Any ideas would be much appreciated.
I agree with #Neil. You can also Add the Calculated field in you data set properties. Take a look at the following screen. You can set the expression to calculate the data for your line chart.
Hope this helps!
I would suggest doing the calculation in your query and then using that computed column in SSRS. If you need help figuring out how to do that, let me know.

iReport query results break-down by week or day

I have used iReport to create a simple JasperReport which I run on a JasperServer. It queries some fields from a number of MySQL tables based on their creation timestamp. I am providing the start and end timestamps of the period to cover in the report as parameters of type java.sql.Timestamp. This works fine.
I was asked to introduce the ability to show a break-down on weeks or days of the report data. I would like to get some ideas on where to start with this. At this point I don't think I can accommodate this 'break-down' in the report query, since this feature seems beyond what SQL is designed to do. I know this sounds like an OLAP drill through, but I would like to avoid OLAP if possible (steep learning curve, tight deadlines).
My first thought was to create a subreport for each week or day . But this would leave me with an arbitrary number of subreports (depending on the overall time period covered by the report, which varies at each execution), and as far as I can tell iReport does not support this.
Here is one way to break the report down.
Create another parameter, groupby, which holds the a value that designates the grouping requirement. The values can be numeric, string or whatever else as long as it corresponds to day, week, month, etc.. grouping available.
Create a report group, breakdown, which will provide the breakdown. The group expression will depend on the groupby parameter. The expression is the date on the record except any detail finer than groupby value will be trimmed.
Create a variable, total, that will sum the data in the records. The variable should be reset on breakdown group and can be printed in the breakdown trailer band.
Make sure the sql queries sortby the date so that the groupby expression works.
Let me know if you have questions.