i have two Data Sources. Each DataSource has some DataSets. What i want is a tablix to retrieve data from different datasets of those two DataSources. But it seems like that in a tablix i can just select one datasource at the same time. I cannot change datasource after select it.
I've tried the sql for each DataSource, there is no problem. But i have no idea about how to select different datasets from two different DataSources.
Appreciated for any suggestion!
You can select from more than one datasource if you use the expression editor for each field's value.
In the editor, click on "Datasets" in the lower left box (called "Category:"), and choose the dataset you want to get the value from in the lower middle box, and then in the lower right box, choose the field from that dataset that you want to get.
You will have to choose some aggregate function on the field, because when you use multiple datasets this way, you can't expect the tablix to be able to populate one table row per data row. But if your dataset only returns one row, you can simply use the First() function for pretty much any value you want to get.
Related
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.
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.
I have 4-5 tables of single and many rows per ID. I want to generate a summary table listing each ID along with various counts and max/mins, but I want to be able to filter on calculations. Example: "ID" is the identifier and there are two tables, TestA and TestB.
One desired selection criteria: Show only those IDs where at least one TestA score >5 and there is at least one TestB score.
In a straight table, this is simple to do with expressions, but the resulting table cannot be selected on the calculated true/false value.
I think I need to create a new table in the load script containing the ID, and then various conditions labeled as I wish. Then, these fields could be dimensions. This seems similar in concept to a master calendar. Am I on the right track?
If it helps to understand my example, this a medical application; the tables are lab results and other interventions that each require complex queries pulling data from various sources that are very "hard-coded" to produce a small data set from millions of rows of highly normalized source data. The desired dimensions would be combinations of the labs so as to allow identification of patients who meet certain criteria--then, once filtered, there would be many more graphs and charts to identify what tests and procedures were followed for that group of patients.
My current data model just loads many tables which then associate on ID. I had attempted to load all data into one big table using concatenates and calculations, but this did not seem to accomplish what I needed and was difficult to manage.
IIUC, I think what you want to do can be accomplished with a combination of sliders/input boxes, variables and calculated dimensions in your table. The process is definitely burdensome, but it should allow you filter the way you want.
Add a field to your table load statement in your script like rnum as RowNo().
Create a variable for your filter(s). Ex. vFilterTestAScore.
Add a slider or input box to your dashboard and point it to that variable.
a. For slider, the option is in the General tab -> Data header -> select the Variable radio button.
b. For input box, add the correct var from the list to the list of Displayed Variables.
Set sliders/input boxes to the criteria you want: vFilterTestAScore = 5 and vFilterTestBScore = 1
Create a straight table with ID as the dimension and expressions for TestAScore and TestBScore. The expression formulas would be sum(TestAScore) and sum(TestBScore) respectively (this won't make sense until the next step).
Now add a calculated dimension to you table. The idea here is that rather than just having the ID dimension, you will create a calculated dimension that only displays the ID of the records that meet the criteria you select in the slider or enter in the input box. The formula should be something like:
if(aggr(sum(TestA), rnum) >= vFilterTestAScore, ID, null()) or for multiple filters: if((aggr(sum(TestA), rnum) >= vFilterTestAScore) and (aggr(sum(TestB), rnum) >= vFilterTestBScore), ID, null()).
On your new calculated dimension, check the 'Suppress When Value is Null' box so only results that meet your criteria are displayed in your table.
To summarize, you are using the variables to store your selection criteria which you are entering via input box or slider. Then you are conditionally displaying only the ID's in your table that match those criteria via a calculated dimension and 'Suppress When Null' option.
I can send you a .qvw if you aren't using the free personal edition and are able to open other qvw's.
I have a split form based on a table (tblMain). The form shows many columns some of which are textboxes and others are comboboxes. I can easily sort and filter every column in a datasheet part of the form except of two columns.
These two columns are comboboxes which have the same control source and same row source table however with the following difference:
cboPUNUM:
control source tblMain.[PU_ID];
row source SELECT tblPU.[PU_ID], tblPU.PUNUM FROM tblPU;
cboPUTYPE:
control source tblMain.[PU_ID];
row source SELECT tblPU.[PU_ID], tblPU.PUTYPE FROM tblPU;
Table tblPU has the following structure:
PU_ID PUNUM PUTYPE
1 11234 SMC
2 21234 DPL
3 11234 NEC
4 21123 SMC
and so on...
The idea is to have two separate columns for PUNUM and PUTYPE in the split form and be able to filter them.
Both columns in the split form show all available values in checkboxes for filtering in the drop-down list on top of columns until the filter is applied:
The problem is that I can filter only one of these columns (see the picture below). For example if I select 84174 in the PUNUM field then I lose an ability to filter PUTYPE field. Ideally PUTYPE should give me an option to check FHP or ADH but checkboxes don't appear in a drop-down list.
And vise versa, if I start from filtering the PUTYPE, i.e. I select FHP and expect the PUNUM to have many options but it doesn't show checkboxes for filtering (see below).
Please advise what I can do with this as I have no ideas...?
P.S. DLookup function instead of comboboxes doesn't allow to filter columns at all.
I know that I can base the form on a query and save DLookup expressions in that query, but it significantly slows down the performance.
Ok, Looks like I was over thinking the issue...
I just changed the query for the split form and included tblPU with those two fields. And then converted form controls to text boxes and sourced them to that fields directly. Works as I wanted.
I want to do a calculation using two different datasets, but I cant seem to do it in the expression field. Any ideas on how I can add, multiply or divide using the two datasets? In the Fields, I added a new one and trying to set the expression only gives me DataSet1, but I want to add a DataSet2 field and a DataSet1 field.
Thanks guys
You can not directly use two data sets in there.
Imho you should move your data to db queries, then add a query that does your job, include this in your report then.
Alternative you can calculate some aggregat in a field, hide the field, do this with more/many as you want, then use your operatores on the result fields.