Filter on Group Expression using lookup to second dataset. SSRS 2012 - tsql

I have two datasets (one is a stored procedure written by a vendor that cannot change). Stored procedure is the main dataset. I am using a second data set to bring back filtered results. The second dataset contains already filtered records.
Trying to use the Tablix filter:
=Lookup (Fields!UserGUID.Value,Fields!UserGUID.Value,Fields!MembershipPolicyGUID.Value, "Dataset2")
I have a group that needs to display only the records in Dataset2.
Dataset2 is written using a where statement only displaying
MembershipPolicyGUID not in'00000000-0000-0000-0000-000000000000' and '29976BA0-E2D7-494E-A1CE-20E609C76929' (these numbers are stored as text)
I need help in how to filter the records.
I have tried the <> in the Tablix filter using the above expression, but it does not work or rather it does not return any records from Dataset2 except those from Dataset1.

Figured it out. The filter should be:
expression =Lookup (Fields!UserGUID.Value,Fields!UserGUID.Value,Fields!MembershipPolicyGUID.Value, "Dataset2")
then operator >
then value 0

Related

Google Sheets QUERY returns non-matching records

In this workbook 1 the second, "DMK Recent" sheet is populated by a query that returns two records that do not meet the [C > date'2019-12-16'] criterion. These are the last two rows on the sheet. To make things more mysterious, those records display values in the C "Date" field that do not match the source data.
If I reduce the size of the source data, only correctly selected records are returned. Is there some source data size beyond which the QUERY() function loses its grip? Many thanks for any light on this.
your query formula:
=QUERY(xFRm!A5:X,
"select A,B,C,D,F,E,K,M,G,J
where C > date'2019-12-16'
and G='THB'
order by C,D", 1)
is is working flawlessly.
the culprits in your case are wrongly entered dates
go and fix rows 4539 and 4540

How to arrange a rowise data coming from hql query into columns based upon particular condition in JRXML

My hql query in JRXML file takes out data rowwise from a table. From this data I need to display some records as columns based upon particular condition.
For example I get data as below:
Subtopic1_Down_1
Subtopic1_Down_2
Subtopic1_Up_1
Subtopic1_Up_2
Subtopic1_Up_3
Currently my jrxml helps me to display data one after another dividing the data with group expression = value of subtopic. All Subtopic1_Down records together in one table. Followed by Subtopic1_Up records in next table and so on for remaining subtopics.
Subtopic1_down
Subtopic1_down_1
Subtopic1_down_2
Subtopic1_Up
Subtopic1_Up_1
Subtopic1_Up_2
Subtopic1_Up_3
But now I want the data to be displayed in such a way that all Subtopic1_Down and Subtopic1_Up records should be displayed in table but different columns as below:
Subtopic1
Down Up
Subtopic1_Down_1 Subtopic1_Up_1
Subtopic1_Down_2 Subtopic1_Up_2
How can I achieve it through Jrxml?
You can make use of scriptlets to modify the resultset row-wise data into column at run time.

Joining two datasets to create a single tablix in report builder 3

I am attempting to join two datasets in to one tablix for a report. The second dataset requires a personID from the first dataset as its parameter.
If i preview this report only the first dataset is shown. but for my final result what i would like to happen is for each row of a student there is a rowgrouping (?) of that one students modules with their month to month attendance. Can this be done in report builder?
The best practice here is to do the join within one dataset (i.e. joining in SQL)
But in cases that you need data from two separate cubes(SSAS) the only way is the following:
Select the main dataset for the Tablix
Use the lookup function to lookup values from the second dataset like this:
=Lookup(Fields!ProductID.Value, Fields!ID.Value, Fields!Name.Value, "Product")
Note: The granularity of the second dataset must match the first one.
We had a similar issue and that can be resolved this way.
First of All, ensure the first data set's query and second data set's query are working fine by executing separately on the Database client tool such as Datastudio.
Build two data sets on SSRS tool with the respective queries and make sure both the data sets have same key column (personID).
On the SSRS report design, create a table from tool box and add the required columns from the first data set along with the matching key column(personID). Add a new column and use look up function to get the required column from the other data set against the same key column (personID).

I need to know if it is possible to create a SSRS report as defined

I have a query with 3 parameters that a user should be able to define:
AND (ORION_SCHED.TRIP.DATE_TIME = '09/11/2012')
AND (ORION.CUST.COUNTRY = 'BE')
AND (ORION_SCHED.TRIP.ID_SHIFT ='1')
DATE_TIME should be a datepicker
COUNTRY dropdown with defined values
ID_SHIFT dropdown with defined values
I guess this isn't an issue?
The result of this query will return the dataset
My actual question: I want the result to be presented in this way
So always 3 blocks of data next to each other, the data of every block is the result of the query filtered down on the column TRUCK_ID (a sub-select of the returned dataset)
The empty cells per block are a nice to have, these are non-unique values per TRUCK_ID that I don't wish to be repeated on every line, but like I said a nice to have.
I would add a new column to the query that returned 1,2 or 3 (for each different TRUCK_ID. Then I would use 3 Tablix (one per column on your report) and filter the data by the new column you added on the query.
Then you just group on the TruckID on each tablix and play around with the format. It should work.

Get 2nd Value in Dataset in Reporting Services

This seems to be a very simple question, but I am trying to get the 2nd value in a dataset to display as a matrix's header value.
In this report, lets say that I have 2 datasets. In Dataset1, I have a query that pulls down 3 values for a parameter dropdown selection. In Dataset2, I return a result set and have bound it to my matrix.
Within the matrix, I have my repeating columns, and then 3 additional grouped columns to the right that have aggrigate values that I want to display. On the header of those 3 columns, I want to display the 3 values displayed in my Parameters dataset. Within the context of the matrix (and its dataset), I can get the first and last values of a different dataset (Dataset1 in this case) by using:
=First(Fields!DateDisplay.Value, "Dataset1")
=Last(Fields!DateDisplay.Value, "Dataset1")
I need to get something like:
=Second(Fields!DateDisplay.Value, "Dataset1")
How do I pull this off without violating the scoping rules on aggregate columns?
For SSRS 2008 R2, you can do this if each row of your dataset has an identifier column by using the LookUp() function.
=LookUp(1,Fields!Row.Value,Fields!DateDisplay.Value,”Dataset1”)
=LookUp(2,Fields!Row.Value,Fields!DateDisplay.Value,”Dataset1”)
=LookUp(3,Fields!Row.Value,Fields!DateDisplay.Value,”Dataset1”)
If you do not have an identifier column you can use ROW_NUMBER() to build one in.
Query:
SELECT ROW_NUMBER() OVER(ORDER BY DateDisplay) AS Row, DateDisplay
FROM Dates
Results:
Row DateDisplay
--- ---------
1 June 1st
2 March 12th
3 November 15th
Here is a link to a similar thread in MSDN Forums: Nth row element in a dataset SSRS
If you are using SSRS-2012 or 2014 then one has to use below expression.
=LookUp(AnyRowNumber, Fields!RowNumber.Value,Fields!DisplayField.Value,”DatasetName”)
I have tried above it was not working in my case.