How to sum calculated fields coming from nested list - reportviewer

In a report I have 2 nested list and the last one has a table inside.
I can easily sum values in the table and have them in the total field.
Inside the nested list I do special calculation with table total value.
I would like to be able to sum all these calculated values in the outer list.
What I need is a way for the nested list to expose its results to the outer list and a way to aggregate them. I don't want and probably cannot do the calculation again in the outer list, I want to sum the results coming from the inner list.
It seems a simple task but I spent the entire morning surfing for a solution !!

Sometimes instead of clicking here and there for a more formal way of adding a solution to thing I many a times find that it could be done in a simple fashion also..
what I mean by this that you can do like following
Right Click tablix row and insert new row below
Now at the cell where you want this aggregated sum total, you can simply use your existing expressions, that you are using in the previous cells, in this new cell where you want to display the results Something like this :
=Sum(Fields!Total1.Value, "DATASET1") + Sum(Fields!Total2.Value, "DATASET2")
See if it works for you, coz I always do like the same !

Related

Static Values from Multiple Queries/Datasets in Single SSRS Tablix

ok so I have this report I have to write in SSRS with a very specific format. It looks like the screenshot below at the bottom. Ignore the arrows and colors. It's pulling from an Oracle database. Each number value cell in this table/matrix has a different sql query to pull it in because they come from different tables, etc.
the top half of the numbers in the table are each from a query. the bottom half of the table is all calculations from the numbers in the top half. I already have the queries for the top half and was trying to figure out how I could just use those to make this table in SSRS with just those and then creating calculations in the bottom half for the report. I can't use a table or a matrix because each query is a different dataset and you can only have one dataset per tablix.
I was thinking maybe doing textboxes and drawing the grid manually, which would be a huge pain. I get errors about not having an aggregate and being out of scope or something and haven't figured out the reason for this yet as it is not my ideal solution.
My current solultion that will eventually get me there is unioning every single query and then creating columns with static values for the rows and columns in the grid and turning it into a matrix. Problem with this is it continues to increase in complexity as I create each further down the table calculation, and the code becomes larger and larger, and takes a long time to create, and I have to do like 6 reports similar in nature to the format of this one. Will probably be a thousand lines of sql and force me to have to make a stored proc because of the ssrs character limitation.;
So my question in a more simple way is, how can I take multiple sql queries that return a static value and make them a single value in a tablix that doesn't repeat, then create more blank rows in that tablix that are calculations of other cells values, i.e. Textbox1 - textbox2, textbox3/textbox4 ?
I got it figured out using expressions with multiple datasets. The answer seemed too easy once I found it. Basically just created a table tablix using my first dataset. Created more detail rows with insert row inside group below. Then I went to the expression builder for each one and found the other dataset and double clicked it to get the expression to pull from the other dataset. For example the bac_labor dataset value would look like this. =Sum(Fields!BAC_LABOR.Value, "BAC_Labor")
Then for calculations can use either same thing like =Sum(Fields!BAC_LABOR.Value, "BAC_Labor") + Sum(Fields!BAC_LABOR_OVERHEAD.Value, "BAC_Labor") or could do something like this =ReportItems!Textbox2.Value - ReportItems!Textbox1.Value to reference a cell value. This saves a ton of time, development effort, and reduction of code for calculations, compared to adding together 500 character select statements to make calculations. Also no need to use stored procs and union or join every select statement together with this method.

Get Sum of Data from Second Dataset in the Second Tablix of SSRS report with Report Builder

I have two different dataset which has a common value placed in two different Tablix in Report Builder tool. I want to achieve a SUM of ELEC_DATA in the second Tablix.
I have already tried using this expression.
=LOOKUP(Field!COMP_ID.value,Field!COMP_ID.value,Field!ELEC_DATA.value,"DATASET2")
The result shows nothing at all -- no errors as well.
Then I tried with custom code.
=code.sumlookup(LOOKUPSET(Field!COMP_ID.value,Field!COMP_ID.value,Field!ELEC_DATA.value,"DATASET2"))
The Result I am getting is "0".
The expected result would be the addition of ELEC_DATA like shown in the pic attached
Looks to me like you're using the LOOKUP function incorrectly. The LOOKUP function only requires 4 parameters to be used.
=LOOKUP([SourceValue], [DestinationValue], [LookedUpValue], "[SourceDataset]")
However, I'm not sure this is the best or even a viable solution to your issue. Honestly, this would be much easier if you were able to combine these two datasets into a single dataset query.
SELECT PAC2_ID, A.COMP_ID, DATE, ELEC_DATA
FROM TABLE1 A JOIN TABLE2 B ON B.COMP_ID = A.COMP_ID
From there, you can use a Grouping on the second Tablix based on PAC2_ID which removes the need for any expressions. It should sum the values automatically when you apply the grouping.
Alright Let's try something like this.
In your 2nd Tablix create one more Column let's call it "PAC2ID_Calculated".
Now for this Column we will use lookup Expression =Lookup(Field!COMP_ID.value,
Field!COMP_ID.value,
Field!PAC2_ID,
"FirstDataset")
Now what will this return in your new Column, It will return PAC2_ID for COMP_ID from first dataset and your 2nd Tablix will be something like below
Once you get this, Group it based on PAC2_ID, you will get expected Result.
You can Hide COMP_ID column.

Trying to count records in SSRS from different data sets

I have an SSRS report that combines 5 reports into one. Each report is populated from a different stored procedure. The first page is a summary that is to provide a record count from each report. I've created fields in the stored procedure that provides the counts for each individual report: phycount and nonphyscount. I'm trying to create a table similar to this:
Active comes from one data set, Initial comes from another, Recert comes from another, etc.
I've been playing around with the Lookup and LookupSet but I'm just getting errors, plus I'm not sure if that's even the right direction.
Does anyone know how to do this?
Lookup and Lookupset are more for getting specific values out of a dataset. Very useful but not necessary for what you're trying to accomplish.
You can use aggregate functions SUM and COUNT to accomplish what you want to do. The cool thing about these functions is you can actually embed IIF statements inside of them.
I'm not sure exactly how your datasets look and are named but it would be something like this...
SUM(IIF(Fields!Type.Value = "PhyCount", 1, 0), "Active")
The sum function goes through every row of your dataset and sums the values you pass to it. The iif statement checks to see if the type field in the dataset is "PhyCount". If so, it returns 1, if not, 0. Since this will happen for every row, your SUM function will return a count of each row with status active.
edit: "Active" after the iif statement specifies the name of the dataset.
EDIT AGAIN: This solution apparently does not work in SSRS 2008.

Im trying to populate a Sharepoint list with the most upcoming dates from certain colums of data from another Sharepoint list?

I have a list named Employee Dates, this list contains the columns:
Employee | CPR Completed | CPR Required | ETC
These columns keep going on for all of the training courses required for our employees with alternating columns for completed and required dates. I am using a workflow to calculate all of the required dates of training from the completed dates.
What I desire to do is make another list that will look at ALL of the columns for the required dates and find the soonest ones and populate that list with the soonest dates and from which column it was pulled from.
Any help as to how to approach this? I have been trying to use queries in Access and also some of the custom view settings in SharePoint Designer but no luck so far.
You could try an Excel table (they also have these functions in access if I recall, but I avoid access like a plague). To connect Excel to share point follow the steps in this article:
support.office.com
Ok, now that we are connected you should see all of the columns and values in excel. Next up we need to find the min date (easy) and then get the associated column name (a little harder).
Min Date: The formula should be something along the lines of =min(B1,B3,B5), jut type in =Min( and then CTRL-click on the columns you want to consider for the row. When your done close with ). After wards double click on the square in the bottom right corner and it will do the same logic for all of the rows.
Column Name: A little more difficult, use the min value from the prior column as the lookup value for VlookUp to get the column name. After wards double click on the square in the bottom right corner and it will do the same logic for all of the rows. I'd explain VlookUp, but I'd run out of characters and attention span long before I got to the relevant parts, and excel functions does a fine job of getting you the basics.
Anyway hope that helps,

Pivot Table Grand Total at the top

We have an Excel spreadsheet with the Grand Totals at the top using a Forumla, but this isn't on the actual Pivot Table it's just in the spreadsheet.
We have a client that wants the Grand Totals at the top of the Pivot Table and doesn't want us to use Formula. Does anyone know if this is possible (even using VBA or something, just so long as we don't look for a specific column or row name and compare with it (so no GETPIVOTDATA("Grand Total...)))?
This slightly hacky solution might help:
http://www.contextures.com/xlPivot13.html
Actually, it is possible. I'm doing just that. Here's how. Let's say I in my data source, I have 1 column that contains various work orders. In another column I have all my total dollars spent for each work order, and in my final column I have a number that identifies all of the various work orders as being part of one whole group, or falling under one heading. In my case, each of the work orders fall under one project number. This will place your total at the top and at the bottom. It will also allow you to turn on and off the bottom or the top by selecting a choice under Grand Total on / off for rows / columns.
Kevin L
I'd be happy to be proved wrong, but I don't think it's possible. I think you may have to do a little work on managing your client's expectations...
It generally works. but many people in my team make different pivot table layouts. So than this "fake" grand total column really does not work anymore.
To anyone having a similar challenge, you can accomplish this by adding rows at top of the pivot table and using GETPIVOTDATA to put the values in any cell you chose. Click here for details on how to use GETPIVOTDATA to get the Grand Total of a column in a Pivot Table. The best part is that is dynamic. There's no need to reference the Grand Total row specifically.