Microsoft Fabric Community Conference 2025, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount.
Register nowThe Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.
Hi All,
My ASP.NET MVC application's URL use three parameters, that is Region, Subregion and Pagenumber from Power BI basic filter. When I run application which gives right results for Region and Pagenumber, but nothing showing for Subregion. My code has given below. I can't figure it out what is wrong here. Help will be appreciated
// for region ,subregion and page level filtering
for (var i = 0; i < hashes.length; i++) {
hash = hashes[i].split('=');
if (hash[0] == "region") {
region.push(hash[1]);
}
if (hash[0] == "subregion") {
subRegion.push(hash[1]);
}
if (hash[0] == "page") {
defaultPage = "ReportSection" + hash[1];
}
}
if (region[0] == undefined) {
region = [];
region.push("VNW","VMP","VGW","VGN","VGE","SOA","QLD","Other","Office","NSW","Display");
}
if (subRegion[0] == undefined) {
subRegion = [];
subRegion.push("VNW","VMW","VMP","VMN","VME","VIC","VCW","VCS","VCN","SOA","QLD","Other","NSW","Display");
}
const filterRegion = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Region Lookup",
column: "Region"
},
operator: "In",
values: region
};
const filterSubRegion = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Sub Region Lookup",
column: "Sub Region"
},
operator: "In",
values: subRegion
};
// Embed configuration used to describe the what and how to embed.
// This object is used when calling powerbi.embed.
// This also includes settings and options such as filters.
// You can find more information at https://github.com/Microsoft/PowerBI-JavaScript/wiki/Embed-Configuration-Details.
var config = {
type: 'report',
tokenType: models.TokenType.Embed,
accessToken: accessToken,
embedUrl: embedUrl,
id: embedReportId,
permissions: models.Permissions.All,
settings: {
filterPaneEnabled: false,
navContentPaneEnabled: false
},
pageName: defaultPage,
filters: [filterRegion, filterSubRegion]
};
// Get a reference to the embedded report HTML element
var reportContainer = $('#reportContainer')[0];
// Embed the report and display it within the div container.
var report = powerbi.embed(reportContainer, config)
Thank You
Please see my screenshot below showing incorrect subregion
That error didn't go away. It says 'This filter can't be used since the corresponding field is invalid'. Thank You
Hi @Palazhi,
Great to hear the problem got resolved! Could you accept your reply above as solution to close this thread?
Regards
Hi @Palazhi,
I have made filterpane true, now getting error in filter pane saying ''This filter can't be used since the correaponding field is invalid '. By default subregion selects ''All'' option.
I can reproduce the same issue when the table name or column name in the filter is not match with the real table name and column name in your model. Note that they are case sensitive. So could you go to check if the table name and column name are correctly set in your filter?
const filterSubRegion = { $schema: "http://powerbi.com/product/schema#basic", target: { table: "Sub Region Lookup", column: "Sub Region" }, operator: "In", values: subRegion };
Regards
Hi @Palazhi,
The main code above looks fine to me, and it works fine in my test.
Have you tried debugging the code to see what's wrong with it?
In addition, could you try setting filterPaneEnabled to true in the configure to see what's in the Filter Pane with the code?
var config = { type: 'report', tokenType: models.TokenType.Embed, accessToken: accessToken, embedUrl: embedUrl, id: embedReportId, permissions: models.Permissions.All, settings: { filterPaneEnabled: true, navContentPaneEnabled: false }, pageName: defaultPage, filters: [filterRegion, filterSubRegion] };
Regards
User | Count |
---|---|
3 | |
3 | |
2 | |
2 | |
2 |
User | Count |
---|---|
10 | |
4 | |
4 | |
3 | |
3 |