SSRS set last row as default value for multi-value parameter - reporting-services

I guess that's easy... I have a multi-value parameter that got the list of values from a query. I would like to select as default value the last row.
Can I achieve this using a expression? I would like to avoid creating a second query just to get the last value from the previous query...

In the default parameter expression you can't refer to the field of the dataset, so you can't write something like Last(Field!MyVar.Value, "DataSet1"), as a workaround you can order your dataset to retrive last row as first and use "Get values from a query" which choses first row, if you can't do this then replicate your dataset in the only one solution.

I am working with SSRS 2012 and I was using a multi select option on my report so when I chose the "Get Values from a query" I got all of the values as the default.
I did find a solution. In my report I needed the default name of the town to be the first one so I created another set with the name of the column and a calculated measure that said "[DimTahanot].[Tahana Name].&[אילת]" and filtered it by the same one. (Please ignore the different language). Although hard coded it was good for this report. You could create another hidden parameter for this set if you need it to be the first one by amount or any other parameters that should effect this value, using the filter as a parameter.
Hope this helps.

Related

How to customize TaxReport_IT - report SSRS?

I would like to custom the Report SSRS TaxReport_IT, I need to add a new field in order to use in to SyntethicReport Design.
(for example)
The classes involved seems these:
TaxReport_IT
TaxReportDP_IT
TaxReportController_IT
TaxReportContract_IT
Tables involved:
TmpTaxReport_ITSummary
TmpTaxReport_IT
TaxReportTmp_IT
Are there others? Are there some Queries involved?'
I added the new fields in to table _TmpTaxReport_IT_, and I pupulated the related tables
I'm sure, in to the method I pupulated correctly the new Field (I have the values ​​that I expect), but when I print the Report I get a lower value. Seems like I don't take the total data set.
How can I add the new field and take the correctly total value?
I saved the data (about my custom field in a RegularTable) and the sum is correct, but I have mismatch when I print the report.
I think I skip some step to Report DataSet.
I use Dynamics AX 2012.
Thanks in advice!
I have an idea what could be wrong, but I'm making some assumptions. If they are not correct, please edit your question to clarify.
From your screenshot, it looks like you want to add your new custom field in the header section of the report design. I'm assuming the expression of that field looks similar to
=First(Fields!MyCustomFIELD.Value, "TaxReportDS_IT")
Note the First key word in that expression. This indicates that the value for that field should be taken from the first of the records of the report's dataset.
I'm assuming that you calculate the value of the field while the records in table TaxReportTmp_IT are being created so that each record has a different value. Maybe it is a sum of some other field, so the first record would have the smallest value and the last record the highest.
If all those assumptions are correct, you can fix this by changing the First keyword to Last. This indicates that you want to take the value of the last record of the report data set.
See also the documentation of the Last Function.

Display selected values of multi-value parameter in tablix rows

I am designing a report for SSRS. I want the user requesting the report to be able to specify, when they generate the report, from a pre-defined selection some values which should be displayed in a tablix on the report.
I have therefore created a multi-value parameter and populated the Available Values with the options I want the user to be able to select from, and, as expected, when the report is generated the user is able to select one or more of these values.
However, what I now want to do is include a tablix in the report, and display a row for every value in the multi-value parameter that the user selected, with the value displayed in the first cell of the row.
If the values were coming from a data table this would obviously be easy. I've also found answers on how to show all of the selected parameter values in a single textbox using the JOIN function, but I don't want to do that.
The only solution I can think of is to replicate the list of available values in the multi-value parameter in a tablix manually, and link the visibility of each row of the tablix to the selected state of the corresponding value in the multi-value parameter, but that's not very elegant and increases the effort involved in maintaining the report definition.
Any ideas on how to do this? I know the selected values from the parameter simply form an array, but I can't see how to bind a tablix to any data that isn't in a dataset, or how to create a dataset from the parameter values.
Considering that a tablix sources from a dataset, I did some experiments to see how to create a low maintenance solution for you.
Option 1: Create a data set with hard-coded options to match your multi-value parameter and select those options WHERE they exist in the parameter.
Example:
SELECT val
FROM (
SELECT 'opt1' as val
UNION SELECT 'opt2'
UNION SELECT 'opt3'
UNION SELECT 'opt4') a
WHERE val IN (#Param)
Thoughts: easier to maintain than visibility on a table, but still two hard-coded places within the report.
Option 2: Create a dataset that selects the multi-value parameter and splits it by each value. This was my first idea, but I ran into some issues with determining how to actually select the multi-value without a syntax error. I came up with a method that creates a deliminated string in the report and than parsed that string back into rows in the dataset:
Step 1) Within the dataset properties, on the parameter tab, join the multiple values together with a JOIN expression
Step 2) Create a simple query which uses the new SQL Server 2016 function string_split. Note that your database compatibility level MUST be 130 or higher to use this function (SQL 2016+). If this isn't your scenario, there are many string split functions that you can find on Stack Overflow to achieve the same thing.
Fun problem!

SSRS MultiValue Parameter Default not Selecting Any

I am trying to make a multi-value parameter that's based off of a dataset to use another field for the Default values. I created a dataset for the parameter with the users and another column that substitutes an X for the username (op_user) if it's an automation account. Unfortunately, it's not selecting any of the usernames.
I have checked the data and there are no NULL values. I have ran a query to make sure that the columns are equal (the Match column).
It works fine if I use the same op_user column for the default values but none are selected if I use the OPuser column.
Can anyone give me an idea of what else I can try in order to make this work?
The problem that I see is that your "Default Values" column of OPuser now contains an 'X' value that is not in your available values. No values will be selected unless all the default values actually exist in the available values column.
I would suggest that you solve this problem with a second dataset. Just use the logic to generate the OPuser column separately and then use that dataset as your default values. That way you don't have to worry about the 'X' values that you don't actually want to be selected.

SSRS Pass parameter / Field value from 1 table to another

I am using SSRS 2012.
I have two datasets. I have two tables.
The first table contains a contract Id which is used as parameter in the second dataset.
I want to set the parameter as the contractId (ie Fields!ContractId.Value, or ReportItems!Contract1.Value) or something like that but nothing works because of different limitations.
If I would be using a subreport that would have been easy just pass the Field!Contract.Value from the 1st dataset as the parameter for the second and there you go. But since we want to call the report using SQL server agent, I cannot use subreport since the agent is limited and does not accept subreport.
So I believe my only option is to use two different tables, but I still need the value from the first dataset. Also, I don't think LookUp() would work for me as I do not have Ids.
Does anyone already did something like that?
Thanks for any help.
You can create report parameters in which the available values are pulled from a query.
Then just use the parameter in your second data set.

Get Row Count in SSRS Report Builder

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.