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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
alexmcarreira
Frequent Visitor

Power BI JS not applying Visual filters correctly

Hello,

 

I'm currently facing an issue where the visual is loading with the filter applied. The label is correctly identifying the filter applied but the checkbox is not checked. (image below)

 

Category.png

 

When I'm trying to get the filters using javascript I'm getting an error with the following error "Basic filter requires an operator (In | Not)"

 

This was working last week.

 

I've checked the open issues on Power BI Support and, currently, there is none with this issue.

 

As something changed on the API?

 

Thank you.

5 REPLIES 5
MattCalderwood
Responsive Resident
Responsive Resident

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

 

Hello,

 

Do you have any news on this issue?

 

Thanks

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
}





Anonymous
Not applicable

Hello Matt,

 

Any updates regarding this issue? Have you had the chance to test this with the hierarchy?

 

Regards,

Rúben

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors