Forum Discussion
How to get and set parameters on an Embedded Paginated Report
- 3 years ago
EDIT: It appears the preferred way to pass these parameters is via the parameterValues property of IPaginatedReportLoadConfiguration. However, it seems IPaginatedReportLoadConfiguration is not importable from powerbi-client...
https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/embed-paginated-report
EDIT2: IPaginatedReportLoadConfiguration is importable from powerbi-client.models.
private _paginatedReportConfig: models.IPaginatedReportLoadConfiguration = { type: 'report', id: '', embedUrl: undefined, tokenType: models.TokenType.Embed, accessToken: '', parameterValues: [ { name: 'StartDate', value: '05/01/2023' }, { name: 'EndDate', value: '05/22/2023' }, { name: 'OtherParam', value: '86' }, ], settings: { commands: { parameterPanel: { enabled: this.showParams, }, }, }, };ORIGINAL:
https://learn.microsoft.com/en-us/power-bi/paginated-reports/parameters/pass-report-parameter-url
I found one solution, passing parameters as query parameters in the EmbedUrl. I need to confirm that their is a way to disable the parameters section of the paginated report. I think it can be done by hiding all the params in Report Builder or maybe with a client-side option.
Below is some basic code appending 3 parameters to the EmbedUrl.
var paginatedReport = pbiClient.Reports.GetReportInGroup(workspaceId, paginatedReportId); paginatedReport.EmbedUrl += "&rp:StartDate=05%2F01%2F2023"; paginatedReport.EmbedUrl += "&rp:EndDate=05%2F22%2F2023"; paginatedReport.EmbedUrl += "&rp:OtherParameter=99"; var tokenRequest = new GenerateTokenRequestV2( reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(paginatedReportId) }, datasets: !string.IsNullOrEmpty(paginatedReport.DatasetId) ? new List<GenerateTokenRequestV2Dataset> { new GenerateTokenRequestV2Dataset(paginatedReport.DatasetId) } : null, targetWorkspaces: new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(workspaceId) }, identities: effectiveIdentities ); pbiClient.EmbedToken.GenerateToken(tokenRequest);
EDIT: It appears the preferred way to pass these parameters is via the parameterValues property of IPaginatedReportLoadConfiguration. However, it seems IPaginatedReportLoadConfiguration is not importable from powerbi-client...
https://learn.microsoft.com/en-us/javascript/api/overview/powerbi/embed-paginated-report
EDIT2: IPaginatedReportLoadConfiguration is importable from powerbi-client.models.
private _paginatedReportConfig: models.IPaginatedReportLoadConfiguration = {
type: 'report',
id: '',
embedUrl: undefined,
tokenType: models.TokenType.Embed,
accessToken: '',
parameterValues: [
{ name: 'StartDate', value: '05/01/2023' },
{ name: 'EndDate', value: '05/22/2023' },
{ name: 'OtherParam', value: '86' },
],
settings: {
commands: {
parameterPanel: {
enabled: this.showParams,
},
},
},
};
ORIGINAL:
https://learn.microsoft.com/en-us/power-bi/paginated-reports/parameters/pass-report-parameter-url
I found one solution, passing parameters as query parameters in the EmbedUrl. I need to confirm that their is a way to disable the parameters section of the paginated report. I think it can be done by hiding all the params in Report Builder or maybe with a client-side option.
Below is some basic code appending 3 parameters to the EmbedUrl.
var paginatedReport = pbiClient.Reports.GetReportInGroup(workspaceId, paginatedReportId);
paginatedReport.EmbedUrl += "&rp:StartDate=05%2F01%2F2023";
paginatedReport.EmbedUrl += "&rp:EndDate=05%2F22%2F2023";
paginatedReport.EmbedUrl += "&rp:OtherParameter=99";
var tokenRequest = new GenerateTokenRequestV2(
reports: new List<GenerateTokenRequestV2Report>() { new GenerateTokenRequestV2Report(paginatedReportId) },
datasets: !string.IsNullOrEmpty(paginatedReport.DatasetId) ? new List<GenerateTokenRequestV2Dataset> { new GenerateTokenRequestV2Dataset(paginatedReport.DatasetId) } : null,
targetWorkspaces: new List<GenerateTokenRequestV2TargetWorkspace>() { new GenerateTokenRequestV2TargetWorkspace(workspaceId) },
identities: effectiveIdentities
);
pbiClient.EmbedToken.GenerateToken(tokenRequest);