SSRS: In a chart group by combining two datasets - sql

I have a report that in the values I have 2 data sets, and then grouping by a location to display the data. If I use the one location within 1 dataset then sure one of the averages I am displaying is perfect but the other is incorrect showing the same result across the board.
No down I need to join these together to get an outcome.
here is what I have:
Values:
1. =Avg(Fields!Rating.Value)
2. =((sum(Fields!Low_rating.Value,"MIN_MAX_CCR") + sum(Fields!Max_rating.Value, "MIN_MAX_CCR")) / 2 ) / Count(Fields!Case_ID.Value, "MIN_MAX_CCR")
Category Grouping:
1.=lookup(Fields!CaseID.Value,Fields!Case_ID.Value, Fields!location.Value,"MIN_MAX_CCR")
So the first field is from the current dataset, the second is from the MIN_MAX_CCR dataset, the location is from the first data set, and then getting the data set for the case_ID.
Now when I run this I get this lovely error:
System.Web.Services.Protocols.SoapException: The Group expression for the grouping ‘Chart8_CategoryGroup’ refers to the field ‘location’. Report item expressions can only refer to fields within the current dataset scope or, if inside an aggregate, the specified dataset scope. Letters in the names of fields must use the correct case.
at
I just cant see a way around this - I cant combine the data in one query due to the nature of the query differences.

You are trying to return location from MIN_MAX_CCR, but it doesnt exist.
I would read the documentation or intellisense hints on the Lookup function to learn how to write it correctly.

Related

SSRS Chart Data - Filtering options for Values?

I'm currently running Visual Studio 2010 for reporting for pharmaceutical batch production. The system creates archive data table with the following fields:
-VARIABLE, which is the name of the variable,
-TIMESTAMP, the time when the value of the variable was recorded,
-VALUE, the actual value of the variable at a specific timestamp,
and so on.
The dataset I'm concerned with contains 3 variables: Level, BatchTimer, and BatchID.
Goal: What I want to achieve is to have Level as the Y value, BatchTimer as the X-axis(Category Group), and BatchID as the Series Group. Therefore I tried putting the VALUE field for all three regions, and adding filter options for the Category Group and the Series Group. Here are the filter options I added:
Filter Option for Category Group
Filter Option for Series Group
The problem now was filtering the Y value so that it only has field VALUE of Variable Level. I then assumed I needed to add a filtering expression to the value region of the chart data, which I don't know how to.
So my question is:
Is this the correct way to approach my goal?
If so, how would I go about filtering the Y value so that it only shows a certain variable in a dataset(in my case, Level)?
Thank you in advance!
If I understand your problem statement correctly, Your end goal is to filter out Level values, i.e For Example Level has values 1,2,3..10 but you want your Level values to be let's say only 3.
So return all data where level is 3. Once you have this datset, you are already able to add BatchTimer as the X-axis(Category Group), and BatchID as the Series Group.
You need a Parameter of a Filter in your dataset something like below.
Now above way is static for Level=3.
How do we make it dynamics
We create a Parameter and ask user to give level. Then depending on this parameter value we filter dataset as below ( this should be added to dataset query)
level field Operator: = and value of the parameter
(Parameters.level.Value)

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.

Reporting Services - Two filters on the same chart Category Group?

I have sales data that I'd like to plot on my chart. However, at a specific point in time, we had a change taking place I'd like to ensure is clearly visible in the chart, preferably by dividing the sales data (which is stored in a single SQL Server column) into two different chunks, which would allow me to then treat them as different data series.
I used to solve this in Excel by storing the post-event data in a different column (by simply dragging them to a different column), and thus I was able to treat them as a different series (the blue and green line in the chart below. The red and orange line are pre-event and post-event averages):
I'd like to reproduce this effect in SSRS, but am not sure how to tackle it. I've tried using an approach where I added two category groups, both pointing to the date-time column, and applying filters to them (one <= the cutoff date, the other >=).
I then added my sales data twice, with the idea I could somehow connect them to the individual category groups, but that does not seem possible.
Has anyone tried anything like this before, or would have a different approach to achieve what I'm trying to get?
Thanks!
I managed to get this to work, and figured I'd share how to do it.
My dataset contains a field called DATEKEY, which stores the date in the format YYYYMMDD. It's possible to use this in an expression and evaluate the date for a specific row. In case the expression evaluates to true, we display the value. If not, we display a blank string.
In case we want to show the values prior to the date, the expression would be:
=IIF(Fields!DATEKEY.Value <= 20130601, Avg(Fields!My_NUMBER.Value), "")
The second series can then be made by reversing the symbol:
=IIF(Fields!DATEKEY.Value >= 20130601, Avg(Fields!My_NUMBER.Value), "")
The graph then looks like this:

Qlikview Expression to get Average in comparison to selected criteria for Chart

I am trying to create a chart that displays the average of a parameter of an entire category. The problem is that in sheet 1,2,3,4, etc, the charts I have reflect one parameter, so when I go to compare this parameter to the average in my new sheet, I only get the average of the fields that have been selected in prior sheets. I want it so that I can create a new chart with one bar as an average of the entire population, and another bar in the same chart that depicts the average of the selected parameter(s). Ideally, I would have two dimensions/x axis categories, one for the selected criteria, and one for average of all categories. Can someone help?
Thanks.
I believe the way to handle this is with set analysis. You can create one expression with the normal avg(parameter) and another expression with some embedded set analysis. See example below.
Expression1: avg(parameter) // will agregate everything in the current selection
Expression2: avg({1<category='YourCategory'>}parameter) // will aggregate everything in a category that you set in the set analysis syntax.
With some more specific info I would be able to get you an actual expression, but hopefully this helps.
EDIT
Updated to reflect new information provided in the comments.
Expression1: avg(parameter)
Expression2: avg({1}parameter)
In set analysis syntax the {1} means the entire universe of data where as {$} is your current selection. In other words, 1 is your data with nothing selected. In my first example above, the {1<category='YourCategory'>} statement uses a modifier signified by the <> so that you would be performing the aggregation over the entire universe with only the value specified in YourCategory selected.
So if the scenario is that you have currently selected let's say, 5 zip codes, your current selection ({$}) would be those 5 zip codes and the entire universe ({1}) will be as if you selected no zip codes. Therefore comparing those two populations side-by-side in two Expressions should give you the comparison you want.
Caveat: Using the {1} syntax in your expression means that your average of "all zip codes" will always be the average with nothing selected unless you put something in the modifier as in my first example. See this more detailed explanation.