I'm trying to built a report in SSRS where I can display all the skus available to one product in different store.
The only problem is when I do so, it generate a new row for the same product for a sku located in another store.
I would like to regroup them on the same row.
Any idea??
You'll need to add a row group to group by whatever other fields you need in the group, and then for your merged SKU field you can do something like:
=JOIN(LOOKUPSET(Fields!CandidateField.Value, Fields!CandidateField.Value, Fields!SKU.Value, 'DataSet1"), ",")
Replace "CandidateField" with the name of a field that can be "joined" back to itself (this is done by the LOOKUPSET() function) to produce the collection of SKUs you need for each row group. Also replace "DataSet1" with the name of your dataset.
And you can replace the comma with whatever delimiter you want.
The JOIN function is what is concatenating the values together; LOOKUPSET() is providing an input array to it.
Note that this only works in SSRS 2008 R2 or newer.
EDIT: Note that this is one means of doing this via SSRS; you could also handle this in your SQL if you'd prefer.
Related
In SSRS report I have two data sources from two different servers. I have a dataset for each data source and would like to return in a tablix the ids that are in dataset 1 but not in dataset 2.
So if dataset 1 has ids 1,2,3,4,5 and dataset 2 has ids 1,2,3 the report should display 4 and 5. I cannot link the servers. Thanks.
There are several ways to do this.
Common Lookup method
This is the way most people would probably do this
Use the Lookup() function.
Set the tablix row's hidden property to something like
=ISNOTHING(
Lookup(Fields!IDa.Value,Fields!IDb.Value,Fields!IDb.Value,"Dataset2")
) = False
The above, for clarity, assumes the ID column in dataset1 is called IDa and the ID column from dataset2 is called IDb. It will stil work if they have the same name (e.g. 'ID')
Note: Dataset name must be in quotes and is case sensitive.
Using this method returns all the rows and simply hides the ones that do not match your criteria. This may not be ideal if you're exporting the data. If not, see the alternative version below.
Alternative method
For reasonably small datasets - parameter method
... and because I thought it was an interesting approach...
This second method uses a hidden parameter and is easy to setup assuming you have a reasonable small number of records.
Using your example, create a parameter called List2 and set its default and available values BOTH to your Dataset2 query (from your example above). Make the parameter multi-value. You can make this parameter hidden once it's working.
Now Your Dataset1 query can be a simple query like this,
SELECT * FROM Table1 WHERE id NOT IN (#List2)
#List2 will contain the values from datset2 (1,2 and 3) so the query will return only the remaining values.
Note I named the datasets to match your example but the datasets must be created in the order above.
I am generating a table in SSRS based on the selection made by the user on two filters: Filter1 and Filter2 (say). The table so displayed has 10 columns and I wish to add filter option listing all available values for that column for all 10 columns.
Basically, I am trying to replicate the Excel functionality of filtering down data on each and every column.
Please note that I tried creating a new data set and a parameter taking all distinct values for a particular variable. However, I am still not able to get the desired results by filter the tablix on that parameter
Is there a way I can do that?
You'd need to make a new dataset that is a smaller version of your main dataset. It would need to return all potential values for the column(s) you want to filter in a single column to be used in a parameter.
Without seeing the design of the report or the dataset itself it's quite hard to be more specific.
REPORT BUILDER 3.0
I am changing the data sets of our reports to standard data sets. In some cases the names of fields have changed. Despite changing the cells to the new names I get an error of:
"The Group expression for the grouping ‘companyname’ refers to the field ‘companyname’. 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.
"companyname" changed to CompanyName and there is no group by companyname in the Dataset SQL. How can I change that in SSRS?
Whenever I've faced this, the places to check are:
Row Groups
Column Groups
Header text boxes for interactive sorting
9 times out of 10 when I can't find it, it's in the interactive sorting on text boxes.
I am using SSRS 2005. I have a report that has a single parameter "#Serial". Our support technicians enter computer serial numbers into the parameter field and generate a report returning the matching records from the database table. The count of serial numbers is not hard set and ranges from 1 to 100++.
My ultimate goal is to list the serial numbers that do not return a matching record.
In SSRS I have tried using the =JOIN(Parameters!Serial.Value,",") to list all of the parameter values (serial numbers) into a text field. This works fine to list ALL of the parameters passed but I do not know the correct expression to convert the list so it only contains only the un-matched serial numbers.
It was suggested that I use a Left Join in the SQL query, however, I don't know how to get the parameters entered by the technician into a temp table in SQL so that I can Join the two tables.
Any help on either method is appreciated, and alternatives to these two methods are welcome.
wouldn't you use the CountDistinct control for the parameter values
I have built a report using Report Builder 3.0 (that uses SQL Server 2008 R2). Now i wish to now how many records are being fetched from database to the report?
This is possible either by count function in SSRS or by using RANK/ROW_NUMBER function in SQL Query and assigning that as field to the report (RANK/ROW_NUMBER would give us rank to each row and navigating to last page in report would help me getting the total row count).
I tried count function but that counts on some field in the report. For instance = Count(Field!FieldName.value, "DataSetName") Problem in this approach: "FieldName" is not unique in the report and hence the counts get repetitive
Second option: Added Rank/Row_Number but they too use the same kind of fieldName and hence here too the counts get duplicated.
Main Problem: There is no field in my query that is unique (and hence i tried ROW_NUMBER())
How can i find the total row count or rank (for each row) in SSRS 2008?
Use the CountRows function. For example
=CountRows("MyDataset")
will give you the number of rows in MyDataSet.
As someone else mentioned above, I couldn't get CountRows("DatasetName") to work in the header until I wrapped it thusly:CSTR(CountRows("DatasetName")).
In the Tablix control's properties, there's a property name called NoRowsMessage put your message here when no row is returned.
you can't put aggregation values into the detail wihtout grouping.
Solution is below:
=Count(Fields!rn.Value)
I use it inside the column/header row.
I found a workaround for this. First create a data column with the value always set to 1. This will provide a value of one for each row of data.
Query Column
, 1 AS Unit
Use the "RunningValue" function into your report as shown below.
=RunningValue(Fields!Unit.Value,Sum,"DataSet")
This will also work as a 'running sum' if that's something you're looking for.