Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
Hi all!,
Im attempting to set a slicer value upon report load. According to this documentation this can be done:
https://github.com/Microsoft/PowerBI-JavaScript/wiki/Slicers
Could someone please check my code below to see if i'm missing something or help confirm that this functionality is not working?
var filter = new models.RelativeDateFilter( { table: "D_DATE", column: "DATE_VALUE" }, models.RelativeDateOperators.InLast, 30, models.RelativeDateFilterTimeUnit.Days, true ); //relative date slicerObj.push({ selector: new models.VisualSelector("a0625ab0110ec10492e3"), state: filter }); var config = { type: 'report', tokenType: models.TokenType.Embed, accessToken: accessToken, pageName: summaryPage, embedUrl: embedUrl, filters: basicFilter, slicers: slicerObj, //THIS DOESN'T DO ANYTHING? id: embedReportId, permissions: models.Permissions.All, settings: { filterPaneEnabled: true, navContentPaneEnabled: true } };
var reportContainer = $('#reportContainer')[0];
var report = powerbi.embed(reportContainer, config);
Solved! Go to Solution.
Hi @fatgreycat,
There aren't any issues. I made it work with the following code finally. (the main part is as follows.)
var models = window['powerbi-client'].models; const slicer_filter = { selector: new models.VisualSelector("97cc6177cbc5e4a48834"), state: { filters: [ { "$schema": "http://powerbi.com/product/schema#basic", "target": { "table": "DimProduct", "column": "ColorName" }, "operator": "In", "values": [ "Blue" ] } ] } }; var config= { type: 'report', tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed, accessToken: txtAccessToken, embedUrl: txtEmbedUrl, id: txtEmbedReportId, slicers: [slicer_filter], permissions: permissions }; var embedContainer = $('#container')[0]; var report = powerbi.embed(embedContainer, config);
So please check out these things below.
1. The format of the filter,
2. The slicer is an array.
Best Regards,
Dale
Hi @fatgreycat,
Could you please mark the proper answers as solutions?
Best Regards,
Dale
Hi @fatgreycat,
There aren't any issues. I made it work with the following code finally. (the main part is as follows.)
var models = window['powerbi-client'].models; const slicer_filter = { selector: new models.VisualSelector("97cc6177cbc5e4a48834"), state: { filters: [ { "$schema": "http://powerbi.com/product/schema#basic", "target": { "table": "DimProduct", "column": "ColorName" }, "operator": "In", "values": [ "Blue" ] } ] } }; var config= { type: 'report', tokenType: tokenType == '0' ? models.TokenType.Aad : models.TokenType.Embed, accessToken: txtAccessToken, embedUrl: txtEmbedUrl, id: txtEmbedReportId, slicers: [slicer_filter], permissions: permissions }; var embedContainer = $('#container')[0]; var report = powerbi.embed(embedContainer, config);
So please check out these things below.
1. The format of the filter,
2. The slicer is an array.
Best Regards,
Dale
Hi @fatgreycat,
I have consulted some experts. I will update here when I get the answer.
Best Regards,
Dale
Update the report ID: CRI 79433674.
Best Regards,
Dale
Hi Dale,
Sorry I don't understand what you are asking me to do?
Hi @fatgreycat,
Sorry for the confusion. It's a reference to other teams. You don't need to do anything.
Best Regards,
Dale
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
9 | |
6 | |
2 | |
2 | |
2 |
User | Count |
---|---|
4 | |
4 | |
4 | |
4 | |
4 |