SSRS PowerShell Linked report

In this post we create Linked Report using PowerShell script.

Function bellow expect following parameters:

  • $proxy – Reporting Services web proxy, how to get proxy, see this post Connect to Reporting Services with PowerShell
  • $OriginReportPath – Report part of base report
  • $NewPath – path for Linked Report
  • $LinkedName – name for Linked Report
  • $LinkedDescription – Linked Report description

Function uses SSRS Web Service method CreateLinkedReport.

function CreateLinkedReport($proxy,[string] $OriginReportPath, [string]
$NewPath, [string] $LinkedName, [string] $LinkedDescription)
{   
Write-Host "Create linked report: " $NewPath"/" $LinkedName
$prop = New-Object -TypeName SSRS.ReportingService2005.Property
$prop.Name = "Description"
$prop.Value = $LinkedDescription

[SSRS.ReportingService2005.Property[]] $props = @(New-Object SSRS.ReportingService2005.Property)
$props[0] = $prop
try   { 
$Proxy.CreateLinkedReport($LinkedName,$NewPath,$OriginReportPath,$props)
         }
     catch [Exception] 
  {  Write-Host $_.Exception.Message
    }
}

Lets try.

CreateLinkedReport $proxy "/ReportPath/BaseReport" "/NewDir/LinkedReportPath" "LinkedReportName" "LinkedReportDescription"

 

SSRS linked report

Linked reports are very nice feature of Reporting Services, I found it very uses full since it gives you possibility to make many reports from your base report by changing parameters default values. It like Windows shortcut when you create child report from your parent report. This child, linked report does not have its own definition. Definition is taken from parent report, but you can set different parameters and it gives you lots of possibilities for implementation scenarios.

You can make for example different naming convention and structure in your reporting services repository when you can prepare different organisation structure for reports based on its usage or you can develop reports with predefined parameters based on user needs. In organisation structure each user could have different requirements for final view of report.

Linked Reports are created in SSRS Report Manager.

Goal

Create Linked report to Sales Report with default Region code, Australia.

Go to Reporting Services Report Manager to path where is situated report you use like base report. Click on arrow next to the right to the Report name. You can use one of report we created in previous post SSRS Cascading Parameters

Report Sales
Picture 1 – Report Sales

Select Create Linked Report from appeared menu.

Create Linked Report
Picture 2 – Create Linked Report

Name Linked Report in next window. You can fill Description too.

 Linked Report
Picture 3 – Linked Report

By confirming previous step, you can see Linked Report in Reporting Services Manager added. See picture bellow.

Linked report
Picture 4 – linked report

Go to linked report properties, click on right arrow on Linked Report name, select manage and go to parameters.

Linked report - parameters
Picture 5 – Linked report – parameters

Set default value for the Linked Report parameter RegionCode. You can see that if we would like to set default parameter value for GetProvince parameter, we are not allowed since it has default value defined by Query. IN case we would like to use linked reports, we should think about parameters in advance.

Linked report - parameter default
Picture 6 – Linked report – parameter default

See Linked Report on picture bellow.

Sales Report linked report
Picture 7 – Sales Report linked report

Be careful when changing definition of base report. Some changes like changing parameters can invalidate Linked Report and you have to create it again.