cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
kevinbrad06
Frequent Visitor

Custom Visual with Shared Dataset

I've created a custom visual that filters the dataset based on user provided values. Everything works greats in my main report published to the service.

 

However, I have several reports that use the same dataset as their source. In those other reports the filters appear to fire (visuals refresh) but no data is filtered out. Has anyone experienced this? I'm a very novice developer but I believe these are the lines that are causing problems.

 

let target: IFilterColumnTarget = {
table: categories.source.queryName.substr(0, categories.source.queryName.indexOf('.')), // table
column: categories.source.displayName // col1
};
let filter: IBasicFilter = {
$schema: "http://powerbi.com/product/schema#basic",
...(new BasicFilter(
target,
"In",
listItem
))
};

// invoke the filter
this.host.applyJsonFilter(filter, "general", "filter", FilterAction.merge);

Any help would be much appreciated.

 

**Edited to Add Capabilities.json

{
"dataRoles": [
{
"displayName": "Filter Column",
"name": "values",
"kind": "Grouping"
}
],
"dataViewMappings": [
{
"conditions": [
{
"values": {
"max": 1
}
}
],
"categorical": {
"categories": {
"for": {
"in": "values"
},
"dataReductionAlgorithm": {
"top": {
"count": 100000
}
}
}
}
}
],
"objects": {
"general": {
"displayName": "General",
"properties": {
"filter": {
"displayName": "filter",
"type": {
"filter": true
}
}
}
}
}
}
1 ACCEPTED SOLUTION
kevinbrad06
Frequent Visitor

Thank you for your help. It ended up being an extremely easy solution this was just my first attempt at a custom viz. I was using the displayName to pass in the column to be filtered and of course there are scenarios where the user has changed the display name. I grabbed the column name from the query name instead and it is working great.

 

View solution in original post

2 REPLIES 2
dm-p
Super User I
Super User I

Hi @kevinbrad06

It's hard to offer any solid advice with debugging slicers/filters as they are very data-dependent. You can send a set of criteria to the filter API, but Power BI will look at all the available contexts in other visuals on the page and actually determine if the filters are needed, so what you send may not always be applied. If other visuals on the the page should be affected contextually, then this is some cause for concern.

Are you absolutely sure that the filter you're sending has the correct info for Power BI? Assuming you're able to debug your visual against these reports and try to repeat your users' actions, then it might be worth logging the filter object to the browser console using JSON.stringify() or similar to inspect in finer detail.

It is possible that if, for example, null values, or an incorrect property chain when resolving your listItem array from the visual might result in filter values that Power BI can't resolve when it receives your request. This part of the code is not in your OP, unfortunately.

If the above output looks okay from your end, then we might need some more of your code, and possibly some sample data (and a sample of the filter object output) to try and debug further.

Regards,

Daniel





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


My course: Introduction to Developing Power BI Visuals


On how to ask a technical question, if you really want an answer (courtesy of SQLBI)




kevinbrad06
Frequent Visitor

Thank you for your help. It ended up being an extremely easy solution this was just my first attempt at a custom viz. I was using the displayName to pass in the column to be filtered and of course there are scenarios where the user has changed the display name. I grabbed the column name from the query name instead and it is working great.

 

View solution in original post

Helpful resources

Announcements
PBI_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

MBAS on Demand

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

Get Ready for Power BI Dev Camp

Microsoft named a Leader in The Forrester Wave

Microsoft received the highest score of any vendor in both the strategy and current offering categories.

R2 (Green) 768 x 460px.png

Microsoft Dynamics 365 & Power Platform User Professionals

DynamicsCon is a FREE, 4 half-day virtual learning experience for 11,000+ Microsoft Business Application users and professionals.