SSRS 2008, Two Datasets, One Chart - reporting-services

I have two datasets.
One dataset1 has the fields MonthNumber, MonthData.
The other dataset2 has the fields MonthNumber, MonthBase.
I want to use both the MonthData field and MonthBase fields in one dataset to create a chart.
Please help me if anyone has an idea how I can combine both datasets to one or use one field of one dataset into another?

To combine the fields from two datasets without combining the datasets you need to use the LOOKUP function.
To replicate this I created the datasets...
DataSet1
--------
MonthNumber MonthData
------------ ----------
1 12
2 23
3 11
4 8
DataSet 2
---------
MonthNumber MonthData
------------ ----------
1 10
2 15
3 20
4 25
Create a chart as you would normally for DataSet1.
Set the values to MonthData, and the Category Groups to MonthNumber
Then add a new Series in the Values area, and set the expression to
=Lookup(Fields!MonthNumber.Value, Fields!MonthNumber.Value,
Fields!MonthBase.Value, "DataSet2")
This effectively states join The ID fields DataSet1.MonthNumber, to DataSet2.MonthNumber, returning me DataSet2.MonthBase
The design will look like this
And the output like this
See also the reference here from which I derived this answer

Related

T-SQL query procedure-insert

I am wondering if any of you would be able to help me. I am trying to loop through table 1 (which has duplicate values of the plant codes) and based on the unique plant codes, create a new record for the two other tables. For each unique Plant code I want to create a new row in the other two tables and regarding the non unique PtypeID I link any one of the PTypeID's for all inserts it doesnt matter which I choose and for the rest of the fields like name etc. I would like to set those myself, I am just stuck on the logic of how to insert based on looping through a certain table and adding to another. So here is the data:
Table 1
PlantCode PlantID PTypeID
MEX 1 10
USA 2 11
USA 2 12
AUS 3 13
CHL 4 14
Table 2
PTypeID PtypeName PRID
123 Supplier 1
23 General 2
45 Customer 3
90 Broker 4
90 Broker 5
Table 3
PCreatedDate PRID PRName
2005-03-21 14:44:27.157 1 Classification
2005-03-29 00:00:00.000 2 Follow Up
2005-04-13 09:27:17.720 3 Step 1
2005-04-13 10:31:37.680 4 Step 2
2005-04-13 10:32:17.663 5 General Process
Any help at all would be greatly appreciated
I'm unclear on what relationship there is between Table 1 and either of the other two, so this is going to be a bit general.
First, there are two options and both require a select statement to get the unique values of PlantCode out of table1, along with one of the PTypeId's associated with it, so let's do that:
select PlantCode, min(PTypeId)
from table1
group by PlantCode;
This gets the lowest valued PTypeId associated with the PlantCode. You could use max(PTypeId) instead which gets the highest value if you wanted: for 'USA' min will give you 11 and max will give you 12.
Having selected that data you can either write some code (C#, C++, java, whatever) to read through the results row by row and insert new data into table2 and table3. I'm not going to show that, but I'll show how the do it using pure SQL.
insert into table2 (PTypeId, PTypeName, PRID)
select PTypeId, 'YourChoiceOfName', 24 -- set PRID to 24 for all
from
(
select PlantCode, min(PTypeId) as PTypeId
from table1
group by PlantCode
) x;
and follow that with a similar insert.... select... for table3.
Hope that helps.

SSRS grouping on multiple tablix

I have main report that has around 10 tablix and one sub report that has 2 charts. I want the each tablix grouped by same column, but every table uses different datasets. By using List control, we can group the tablix and set a page break between each group. For that, list dataset and tablix dataset must use the same dataset name.But I am not sure how to do that for multiple datasets. Could anyone please help me how to group multiple tablix based on same field value.Is it possible using list to do that? TIA
Attached for reference
. Each tablix uses different data sets.but the field names are same.If Service_line column has 10 rows, then I want to display in 10 pages(one page per service line).If I select page break at each tablix, first tablix splits by that field name,after that next tablix starts to split by that field name. I want to show A/R,cash,Adjustments in one page per service_line field and then next page the same tables but different service_line. So I thought Put in List all tables together and grouping at List level will solve the problem.Could you please help me on that? or if you have any other suggestions please let me know. I am not sure how to get this done. Appreciate your help.
If I understood you correctly, what you want to do is modify your data a little and use nested grouping.
Combine your datasets into one dataset using unions and label each row with column 'Category'that has value ('A/R', 'Cash', 'Adjustments')
for example your dataset might look something like this
CATEGORY | SERVICE_LINE | Total | ...
-------------------------------------
A/R | A | 100
A/R | B | 10
A/R | C | 1000
Cash | B | 50
Adjustments | B | 100
Cash | A | 5
Cash | C | 400
Adjustments | C | -100
Adjustments | A | 9999
after that you will create a 1 tablix (forget about the lists). And inside that tablix you will create a row group for Category and merge all columns and set value for the cell as [CATEGORY]. Also for this row group you want to set Page Break options as "Between each instance of a group". After that create a row below that contains all the column labels Service_line, Total, etc.
Now what you have to do is create one more row group as Adjacent Below and use Service_Line as group by attribute.
with some UI tweaking you can get it to look as you want.

SSIS Not Exists In One Data Flow

I'm trying to achieve the following in SSIS:
Union All 6 separate SQL queries (OLE DB Sources) (call this dataset A)
Dataset A contains
id Col A Col B......
1
2
3
4
5
6
7
8
I have another OLE DB Source SQL query (dataset B) that contains
id Col A Col B .......
1
2
3
4
10
11
12
All columns Col A, Col B etc. are the same in all the queries.
I want to return dataset A unioned (UNION ALL) with dataset B where the ids in dataset B don't match the ids in dataset A. i.e.
id Col A Col B......
1
2
3
4
5
6
7
8
10
11
12
Also before performing the UNION there is some extra work done on dataset B to fill in NULL values in the columns.
I can achieve this quite easily by inserting dataset A into a table then using this table in a subsequent NOT EXISTS or similar query to get the missing info and then UNIONing together. Ideally though I'd like to do this in one sweep using a dual multicast with one side going into a Lookup No match and the other straight into a destination table.
Unfortunately the Lookup and No Match output returns the 'wrong' missing data i.e. it returns
5
6
7
8
rather than
10
11
12
this is because the lookup (dataset B) and source data (dataset A) are the 'wrong way' around. I don't want to rewrite dataset A as the Lookup query so is there another way around this using a different transform or other method?
I've experimented with the Cache Transform but it doesn't seem to work in the same data flow as the Lookup Transform as there is read/write contention.
Thanks,
Rich.
Sounds like you want a "Fuller Outer Join" kind of "Merge" component, then a kinda manual merge after the fact. If I misunderstood you, you can always add a Conditional Split after the Merge, to filter if A is null, if B is null, etc.
An example for the "Merge Columns" is creating a repeated "Id" with this expression: "ISNULL(Id_A) ? Id_B : Id_A"
An example for the "Full Outer Join - Merge":

To calculate sum of the fields in a matrix with column grouping

I am working on a ssrs report with column grouping. the followin is my scenario.
Matrix 1:
ID 2012 2013
1 20 40
1 30 50
Total 50 90
Matrix 2:
ID 2012 2013
1 60 70
1 60 80
Total 120 150
I need the sum of matrix1 and matrix2 like below:
ID 2012 2013
1 170 240
But I got the result like :
ID 2012 2013
1 410 410
I have applied column grouping in all the 3 matrices and gave the expression to get sum for matrix 3 as: =Sum(Fields!amount1.Value, "dsmatrix1") + Sum(Fields!Tamount1.Value, "dsmatrix2")
Please help me to get a solution for this.
Thanks!
I think I know what's going on. Correct me if I'm wrong.
Based on what I'm seeing, I'm guessing that Matrix 1 and Matrix 2 only have three fields each, an ID field, an amount field (being "amount1" or "Tamount1"), and a year field.
Your column grouping is manipulating the display of the data to show all values broken out by year. This works fine when looking at data from a single dataset. However, your formula is specifying that the sum of everything in the Amount1 field of dsmatrix1 and the Tamount1 field of dsmatrix2 should be added. This does not take into account the column grouping. Your expression is essentially taking all of the values from both datasets and adding them together.
Not knowing more about your query structure or how the data is filtered, my best guess is that you need another SQL dataset. In this case, you would take the queries from your two previous datasets and union them with the "Union All" command. Note that you will want to use Union All and not just Union. More on that here: What is the difference between UNION and UNION ALL?
Your end result should look something like this:
--This will be your dsmatrix1 query copied and pasted
Select ...
Union All
--This will be your dsmatrix2 query copied and pasted
Select ...
--Place one single Order by clause at the bottom
Order by ...
Note: for your two queries to be unioned properly, you'll need to make sure that each have the same number of fields, each with the same data types. Then you can point your third matrix to the new dataset.
Hope that helps!

Convert MDX query result into relational format

I have a SQL stored proc that uses a linked server and Openquery to execute a MDX query. The result returned from the MDX query is in the format of:
Month 1 | Month 2 | Month 3 | Month 4
12 5 4 7
where the columns are dynamic i.e. I never know how many months will be in the output.
How can I transpose the output into a relational format e.g.
Two columns.
Col 1 | Col 2
----- -----
Month1 12
Month2 5
Month3 4
etc etc
You'll need to change your original MDX query from something like :
Select
[Months].members on 0
from [MyCube]
to something like this one :
Select
[Measures].defaultmember on 0,
[Months].members on 1
from [MyCube]