Create a Data-Driven Tableau Package
Create a package from input records, map each row to Tableau parameters, and execute and check the resulting reports.
A data-driven package generates Tableau reports for a set of input records. Use each record's values in report parameters, then deliver the resulting files through the package's destinations.
This example uses two agent records to generate two Tableau reports per agent and sends the PDFs to one shared test recipient. For the complete standalone script, see Create a Data-Driven Report Package.
Before you begin
- Complete Authentication and Token Management. The examples use
$AtrsBaseUrland$AtrsHeadersfrom that guide. - Identify the configured Tableau account, both view IDs and their URLs.
- Each view needs a string parameter that selects an agent. Use its actual name in place of
AgentName. - Choose an ATRS folder and a test email recipient. Keep recurring delivery disabled while checking the output.
Run the steps in order in the same PowerShell session. Replace the example agent names with values that exist in your Tableau data.
1. Prepare the input records
$AtrsRows = @(
@{ agent_id="1"; agent_name="John Doe" },
@{ agent_id="2"; agent_name="Jane Doe" }
)
$AtrsValuesJson = ConvertTo-Json -InputObject $AtrsRows -Depth 10 -CompressKeyField identifies the column whose values distinguish the records. Here it is agent_id. Include a nonblank, unique value in every row.
ValuesJson is a string containing a JSON array, not a directly nested array. Serialize the rows first, then serialize the full package request.
2. Build the package and map its parameters
For a Tableau report parameter, <[r]agent_name> supplies the current driver's agent_name value. Name identifies the Tableau parameter; Value supplies the row value. The driver key does not automatically bind a report parameter or email recipient.
Replace the account, view IDs, URLs, folder and recipient in this complete definition:
$AtrsPackage = @{
PackageName = "Agent report package"
FolderPath = "/API Reports"
Description = "Two Tableau reports for each agent"
Keywords = "api,agents"
DataDriven = $true
GroupByEmail = $false
MergePDFFiles = $false
MergeExcelFiles = $false
Schedule = @{
Frequency="Daily"
StartDate=(Get-Date).ToString("yyyy-MM-dd")
EndDate=(Get-Date).AddYears(1).ToString("yyyy-MM-dd")
ExecutionTime="09:00"
HasEndDate=$false
Repeat=$false
Enabled=$false
DailyRepeatInterval=1
}
DataDriver = @{
DataDriverType=1
KeyField="agent_id"
ValuesJson=$AtrsValuesJson
ConString=""
Query=""
GroupReports=$false
}
Reports = @(
@{
tableauAccountId="YOUR_TABLEAU_ACCOUNT_ID"
tableauItemId="YOUR_SCORECARD_VIEW_ID"
reportUrl="https://tableau.example.com/views/Agents/Scorecard"
reportName="Agent scorecard"
customName="Agent scorecard"
ObjectType="REPORT"
outputFormat="Acrobat Format (*.pdf)"
parameters=@(@{ Name="AgentName"; Value="<[r]agent_name>"; Type="String" })
},
@{
tableauAccountId="YOUR_TABLEAU_ACCOUNT_ID"
tableauItemId="YOUR_DETAIL_VIEW_ID"
reportUrl="https://tableau.example.com/views/Agents/Detail"
reportName="Agent detail"
customName="Agent detail"
ObjectType="REPORT"
outputFormat="Acrobat Format (*.pdf)"
parameters=@(@{ Name="AgentName"; Value="<[r]agent_name>"; Type="String" })
}
)
EmailDestinations = @(
@{
DestinationName="Agent report email"
DestinationType="Email"
Enabled=$true
OutputFormat="Acrobat Format (*.pdf)"
To=@("[email protected]")
Cc=@()
Bcc=@()
Subject="Agent reports"
Body="The agent report PDFs are attached."
BodyFormat="TEXT"
}
)
DiskDestinations = @()
}For John Doe's row, each report receives AgentName = John Doe; for Jane Doe's row, each receives AgentName = Jane Doe. The shared email destination is independent of this parameter mapping.
3. Create and retrieve the package
$AtrsCreated = Invoke-RestMethod -Method Post `
-Uri "$AtrsBaseUrl/api/PackageSchedule/Create" `
-Headers $AtrsHeaders -ContentType "application/json" `
-Body ($AtrsPackage | ConvertTo-Json -Depth 100) -TimeoutSec 60
$AtrsPackageId = [int]$AtrsCreated.UniqueId
if ($AtrsPackageId -le 0) { throw "No package ID returned. Check ATRS before retrying." }
$AtrsSaved = Invoke-RestMethod -Method Get `
-Uri "$AtrsBaseUrl/api/PackageSchedule/Get?Id=$AtrsPackageId" `
-Headers $AtrsHeaders -TimeoutSec 30
$AtrsSaved | ConvertTo-Json -Depth 100Check DataDriven, the driver key and rows, both reports' parameters, the destination and disabled recurrence. Retain the package-level UniqueId.
4. Execute and check the output
Use the package execution and monitoring steps in Create and Manage Report Packages, with the $AtrsPackageId returned above. Send ScheduleType: "package", retain ExecutionId, and monitor that same run.
When execution completes, inspect the decoded ResultJson and require a boolean Result: true. Then check the actual PDFs and email:
| Record | Expected result |
|---|---|
| John Doe | Both reports contain John Doe's data and exclude Jane Doe's data. |
| Jane Doe | Both reports contain Jane Doe's data and exclude John Doe's data. |
| Shared destination | The test recipient receives every expected report. |
A Completed status does not replace the content and delivery checks. If output is partial or the outcome is uncertain, keep the execution ID and reconcile the run before submitting it again.
Driver fields and SQL input
| Field | Purpose |
|---|---|
DataDriverType | 1 for JSON rows; 0 for SQL |
KeyField | Column identifying each input record |
ValuesJson | Serialized JSON row array |
ConString | ATRS data-source connection configuration for SQL input |
Query | SQL query returning the driver records |
GroupReports | Driver report-grouping setting |
The JSON walkthrough uses PackageSchedule/Create. For a SQL-backed definition, use Package/Create with DataDriverType: 0, the configured ConString and Query. Supply the complete package, report and destination definition. Package drivers use Query; single-report driver models use SQLQuery.
Grouping and normal delivery
The example leaves merging and email grouping off so you can inspect each record's reports separately. Use GroupByEmail for the package's email-grouping setting, and check the resulting delivery count and file grouping against your intended configuration.
Before enabling recurring delivery, check for missing values, duplicate keys and parameter names that do not match the Tableau views. Keep recipient selection separate from report parameter selection: a correctly addressed email can still contain the wrong report data.
Updated about 8 hours ago