Update the expression of a image field in SSRS from report server - reporting-services

Recently we moved from SSRS 2014 SharePoint mode to native mode. We were able to migrate all the reports but the logos for the reports are defined as expression below, these are external images.
"
Iif(len(Globals!ReportFolder)>0,
Mid(Globals!ReportFolder,1, Iif(InStr(Globals!ReportFolder,"Report Center")>0,InStr(Globals!ReportFolder,"Report Center")-1,0)) & "SiteAssets/ReportImage.PNG",
Globals!ReportServerUrl & "SiteAssets/ReportImage.PNG"):
since the 2019 SSRS reports url is different than the old one( 2014 sharepoint) we have to update 1000+ report's logos. I tried to update the content column in the catalog table with the new url. though it says rows updated, when I view in the XML format, it shows the old one.
Below is what I am doing:
SELECT
ItemID,
[Path]
, CASE [Type]
WHEN 2 THEN 'Report'
WHEN 5 THEN 'Data Source'
END AS TypeName
,Content
, CAST(CAST(content AS varbinary(max)) AS xml) contentxml
, [Description]
into ##rep
FROM ReportServer.dbo.[Catalog] CTG
WHERE
[Type] IN (2, 5) and ItemID='6A4A5246-94FC-4BEF-87F2-716067839E44'
UPDATE ##rep
SET contentxml = REPLACE(CAST(contentxml AS NVARCHAR(MAX)), '=Iif(len(Globals!ReportFolder)>0,
Mid(Globals!ReportFolder,1, Iif(InStr(Globals!ReportFolder,"Report Center")>0,InStr(Globals!ReportFolder,"Report Center")-1,0)) & "SiteAssets/ReportImage.PNG",
Globals!ReportServerUrl & "SiteAssets/ReportImage.PNG")', '=/SiteAssets/ReportImage.png')
WHERE ItemID = '6A4A5246-94FC-4BEF-87F2-716067839E44'
Is there any other way we can update the catalog table so that it updates all the reports logo's URL at once instead of opening each report and update manually.
Any help is greatly appreciated.

Related

Show multiple line chart in SSRS

I am developing report in SSRS where i have to show data over line chart.
Line chart vary on parameter selected by user.
Now my issue is how to produce line chart based on parameter selected. Sometimes line chart may be 2 and sometime it may be 4, based on parameter selected by user.
Please advise how to do so.
In the following example, I used some basic population data, it returns
Country, Year and Population.
here is the SQL to generate the sample data
DECLARE #t TABLE(Country varchar(20), [Year] int, Population float)
INSERT INTO #t VALUES
('France', 2000, 59.0),
('France', 2005, 61.1),
('France', 2010, 62.9),
('France', 2015, 64.5),
('France', 2020, 65.3),
('Germany', 2000, 81.4),
('Germany', 2005, 81.6),
('Germany', 2010, 80.8),
('Germany', 2015, 81.8),
('Germany', 2020, 83.8),
('UK', 2000, 58.9),
('UK', 2005, 60.3),
('UK', 2010, 63.5),
('UK', 2015, 65.9),
('UK', 2020, 67.9)
SELECT * FROM #t
WHERE Country = #Country
The final WHERE clause uses a parameter #Country which will get passed in from the report.
The approach
We will create a report that shows a single country's population, this will be used as a sub report.
We will then create a master report that calls the sub report as many times as is required.
Create the sub report
I created a new report, added a dataset using the query above and called the dataset dsPopulation. This automatically generates the parameter #Country. There is no need to do anything with this parameter as the user will not use it directly.
I then added a line chart to the report and dragged Population to the Values section, Year to the Category Groups section and Country to the Series Groups section as shown below.
Save the report, call it something like _sub_PopulationReport
.
Now create the master report
Create a new report.
Add a new dataset 'dsCountries' that contains a list of distinct countries. You'll have to decide how best to do this. You might be able to do something like SELECT DISTINCT Country FROM myDataTable ORDER BY Country. For this example I will hardcode the list.
The datatset query looks like this,
DECLARE #t TABLE(Country varchar(20))
INSERT INTO #t VALUES
('France'), ('Germany'), ('UK')
SELECT * FROM #t
WHERE Country IN (#Country)
This will automatically create a Country parameter.
Edit the parameter and set the available values list to a list of countries. You can do this either by pointing it to a query of just adding them by hand.
Set the parameter to be Multi-Value
Now add a Table to the report design.
Next, right-click on any of the row or column headers (any one will work) and choose "Tablix Properties". Set the "Dataset Name" option to the dataset you just created (dsCountries).
Next, remove the header row and two of the columns so you are left with one 'cell'.
Make the table wide enough to fit your chart in (the height it not important).
Inside the remaining cell, right-click and choose "Insert => Subreport"
Right-click the <Subreport> placeholder and choose "Subreport properties". Under the option "Use this report as a subreport" choose the report we created earlier (_sub_PopulationReport).
Click the "Parameters" tab on the left then "Add"
Under "Name" choose or type Country and under "Value" choose or type [Country]
That's it!
The report design should look something like this... (note my subreport name is different than above, ignore this.)
If I run the report for and select 1 country I get this..
If I select more countries (all of them in this case) I get this...

SSRS VLookup possible?

Is it possible to use VLookup in SSRS ? I know we can use lookups but I want to create a SSRS report with Vlookup then export it to excel ?
If you don't know difference between lookup and Vlookup then, Vlookup works dynamically, e.g. if you enter value in a textbox, it gets results from datasets in the report.
E.g.
TextBox for OrderId : ______
TextBox for Location : *****
When user adds a orderId location text box gets updated, and it all happens dynamically.
Unfortunately, this isn't possible with SSRS. SSRS will not let you export Excel formulas.
The closest you may be able to get is to have SSRS export the file to a location then have an SSIS job update your file with the formula you want in a Script Task:
...
ExcelFormula = "=SUM(" & SumColumn & "45:" & SumColumn & Row.ToString & ")"
Worksheet.Cells(Row, Column - 1).Formula = ExcelFormula
...
http://bidn.com/Blogs/updating-a-single-excel-cell-using-ssis
Refresh Excel using SSIS script task
https://msdn.microsoft.com/en-us/library/ms403358.aspx

Find the original report of a linked report in SSRS

How to find the original report of a linked report in SSRS. Could anyone let me know how to find the main report of a linked report in the report manager.
To find the original report open Report Manager (YourReportingServer/Reports/Pages/Folder.aspx) in your browser and select 'Manage' in the option menu of report.
There in properties you can see 'Link to' field that's the main report and you can change it here.
You can also query in TSQL the list of linked reports.
SELECT
[Original_Report] = [prt].[Path]
, [Linked_Report] = [rpt].[Path]
FROM
[ReportServer].[dbo].[Catalog](NOLOCK) AS [rpt]
LEFT JOIN [ReportServer].[dbo].[Catalog](NOLOCK) AS [prt] ON [prt].[ItemID] = [rpt].[LinkSourceID]
WHERE
1 = 1
AND [rpt].[Type] IN(4);

Print description from Report Properties to report footer.

Is it possible to use the Description Field in the Report Properties and print that on the footer? I have looked and did not find anything.
You can I think but it is a lame answer. You need to deploy the report and then check the catalog table in the ReportServer database of what you just deployed. As far as I have ever read or tried the 'Globals' and 'ReportItems' do not contain it, yet the database does. EG:
Create a variable named ReportName and have it's default be
=Globals!ReportName
Ensure the parameter is set to 'Internal' as you don't want users to see it.
Create a data set to get the name and description of your report
SELECT Name, Description
FROM ReportServer.dbo.Catalog
WHERE Name = #ReportName
Drag and drop the 'Description' of the new dataset to your Report Footer.
You must first deploy the report for the item to be in the catalog as the database is what is on the hosted server. Not what you are working on in BIDS.

SSRS: ASP.NET ReportViewer parameters reset to default when clicking View Report

I have a SQL Reporting Services report (SQL 2008 built using Report Builder v2.0) which has a multi select integer parameter (in this case a list of stores).
The default value is 0 ("All Stores"). The parameter is passed to a stored procedure as a varchar(1024).
This all works fine in Report Builder or from the Reporting Services website.
However from an ASP.NET website using the ReportViewer component the parameters are reset to the default each time you choose "View Report".
I've tried setting the view to non-asynchronous loading (changes the rendering container?) plus any other setting I could find, without success. Does anyone know a trick to fix this?
I made a mistake. The ReportViewer control was inside a Master Page. Each time the "View Report" button was clicked it did a postback and reset the session.
I added if (!IsPostBack) to before the report setup method.
For those of you who experience this error for reasons not listed by the original poster...
Here is a similar scenario.
You have a report which uses a multi-select report parameter.
This parameter is populated by a datasource, which bases its values off some table query.
When you use the 'Select All' option for this report parameter and press the 'View Report' button, the parameter is reset to blank and your report is not generated.
I believe this problem occurs because something invalidates your dataset while the query is being performed, but I cannot be 100% certain.
What I do know, is that by using a table variable as the dataset's query source, you make this problem go away.
For example, your CityDataSource could be populated by the query:
SELECT DISTINCT city, city as SortOrder from accounts
UNION
SELECT 'All' as city, '0' as SortOrder
ORDER BY SortOrder
If you've been making SQL Reporting Services reports, you may have stumbled upon this solution once or twice.
Now, we change the CityDataSource query to look like the following:
DECLARE #citytable TABLE (city varchar(255), sortorder varchar(255))
INSERT INTO #citytable (city, sortorder) VALUES
(
SELECT DISTINCT city, city as SortOrder from accounts
)
SELECT city, sortorder FROM #citytable ORDER BY sortorder
And by doing that your report's parameters won't reset anymore.
A stored procedure would also work, I suspect.
I found a similar code error as the original poster. I was (re)setting the report server credentials every time the page was loaded, instead of just when it was initialized. Apparently, setting the report credentials resets all of the parameters.