Forum Discussion
Power BI JS not applying Visual filters correctly
Hi alexmcarreira
I am not aware of any recent changes to the filter structures (doesn't mean it hasn't happend) ๐
Are you able to share the filter object/code-structure that you are applying to your report?
Cheers,
Matt
Hello,
This is the filter structure that I'm applying to the visual in question.
[
{
"$schema": "http://powerbi.com/product/schema#basic",
"target": {
"table": "Product",
"hierarchy": "Product Hierarchy",
"hierarchyLevel": "Category"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "In",
"values": [
"Mix"
],
"requireSingleSelection": false
},
{
"$schema": "http://powerbi.com/product/schema#basic",
"target": {
"table": "Product",
"hierarchy": "Product Hierarchy",
"hierarchyLevel": "Segment"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "http://powerbi.com/product/schema#basic",
"target": {
"table": "Product",
"hierarchy": "Product Hierarchy",
"hierarchyLevel": "Product"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "http://powerbi.com/product/schema#basic",
"target": {
"table": "Sales",
"measure": "Total Sales"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "http://powerbi.com/product/schema#basic",
"target": {
"table": "Sales",
"measure": "Total Sales (py)"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
},
{
"$schema": "http://powerbi.com/product/schema#basic",
"target": {
"table": "Sales",
"measure": "% Sales Growth vs PY"
},
"filterType": 1,
"displaySettings": {
"isHiddenInViewMode": false
},
"operator": "All",
"values": [],
"requireSingleSelection": false
}
]
Thanks.
Alexandre Carreira
- alexmcarreira6 years agoFrequent Visitor
Hello,
Do you have any news on this issue?
Thanks
- Anonymous6 years agoNot applicable
Apologies alexmcarreira for the delay in responding, it has been a crazy few days.
I was going to try and replicate this in a solution - as I had never tested JavaScript filters against a hierarchy before.
(I am yet to get around to this).
One thing I did notice... was the use of 'ALL' inside some of the basic filters.{ "$schema": "http://powerbi.com/product/schema#basic", "target": { "table": "Sales", "measure": "Total Sales (py)" }, "filterType": 1, "displaySettings": { "isHiddenInViewMode": false }, "operator": "All", "values": [], "requireSingleSelection": false }
My understanding is that this is not a valid operator for this filter type... and is probably the reason for the "Basic filter requires an operator (In | Not)" error.
If you want to default to having ALL values selected, then you should either not supply the filter definition at all... OR select "IN" with an empty array. The last time I used this, it behaved in the same was as having all options selected.
I will try and get some time to look at testing this with the hierarchy, just in case that is the cause of your original issue...{ "$schema": "http://powerbi.com/product/schema#basic", "target": { "table": "Product", "hierarchy": "Product Hierarchy", "hierarchyLevel": "Category" }, "filterType": 1, "displaySettings": { "isHiddenInViewMode": false }, "operator": "In", "values": [ "Mix" ], "requireSingleSelection": false }- Anonymous4 years agoNot applicable
Hello Matt,
Any updates regarding this issue? Have you had the chance to test this with the hierarchy?
Regards,
Rรบben