Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Palazhi
Regular Visitor

Power BI Report level Filters not working properly in ASP.NET MVC application

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

7 REPLIES 7
Palazhi
Regular Visitor

Please see my screenshot below showing incorrect subregion

img.png

That error didn't go away. It says 'This filter can't be used since the corresponding field is invalid'. Thank You

Palazhi
Regular Visitor

Hi there,
You were right. In my region filter, the condition is Region ''in'' but for subregion the condition is ''notIn'' .First I tried to change the code as from operator: "In" to operator:"NotIn", but it didnt work. Then I have changed in Power BI Desktop then published it. Now it's working. Thank you so much for your support

Hi @Palazhi,

 

Great to hear the problem got resolved! Could you accept your reply above as solution to close this thread? Smiley Happy

 

Regards

Palazhi
Regular Visitor

Hi,
Thank you for responding back to me. 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.

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? Smiley Happy

const filterSubRegion = {
$schema: "http://powerbi.com/product/schema#basic",
target: {
table: "Sub Region Lookup",
column: "Sub Region"
},
operator: "In",
values: subRegion

};

 

Regards

v-ljerr-msft
Microsoft Employee
Microsoft Employee

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? Smiley Happy

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]
};

filterpane1.PNG

 

Regards

Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.